jkomoros / card-web

The web app behind thecompendium.cards
Apache License 2.0
46 stars 8 forks source link

gulp commands broke when running as npm scripts #663

Open jkomoros opened 1 year ago

jkomoros commented 1 year ago

When the package switched to use type: module gulp broke. If you run it from the CLI it works... but if it runs from an NPM script, it fails.

That means that commands like npm run start and npm run test (both of which have a gulp inject-config) don't work.

https://stackoverflow.com/questions/60209196/gulp-throws-error-must-use-import-to-load-es-module

This broke at 886c6e223c8bede019dbff6b0b42edde79375867 .

92c2919f75ec916631d88ac95507aecc53ce1797 and e52bba224ee61a8f2f8acf73722fb6e2e7f882ab are also related

jkomoros commented 1 year ago

The error looks like


/Users/jkomoros/Code/card-web/node_modules/gulp/node_modules/gulp-cli/lib/versioned/^4.0.0/index.js:36
  var exported = require(env.configPath);
                 ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/jkomoros/Code/card-web/gulpfile.js from /Users/jkomoros/Code/card-web/node_modules/gulp/node_modules/gulp-cli/lib/versioned/^4.0.0/index.js not supported.
Instead change the require of gulpfile.js in /Users/jkomoros/Code/card-web/node_modules/gulp/node_modules/gulp-cli/lib/versioned/^4.0.0/index.js to a dynamic import() which is available in all CommonJS modules.
    at execute (/Users/jkomoros/Code/card-web/node_modules/gulp/node_modules/gulp-cli/lib/versioned/^4.0.0/index.js:36:18)
    at Liftoff.handleArguments (/Users/jkomoros/Code/card-web/node_modules/gulp/node_modules/gulp-cli/index.js:201:24)
    at Liftoff.execute (/Users/jkomoros/Code/card-web/node_modules/liftoff/index.js:201:12)
    at module.exports (/Users/jkomoros/Code/card-web/node_modules/flagged-respawn/index.js:51:3)
    at Liftoff.<anonymous> (/Users/jkomoros/Code/card-web/node_modules/liftoff/index.js:191:5)
    at /Users/jkomoros/Code/card-web/node_modules/liftoff/index.js:149:9
    at /Users/jkomoros/Code/card-web/node_modules/v8flags/index.js:138:14
    at /Users/jkomoros/Code/card-web/node_modules/v8flags/index.js:41:14
    at /Users/jkomoros/Code/card-web/node_modules/v8flags/index.js:53:7 {
  code: 'ERR_REQUIRE_ESM'
}
/Users/jkomoros/Code/card-web/node_modules/gulp/node_modules/gulp-cli/lib/versioned/^4.0.0/index.js:36
  var exported = require(env.configPath);
                 ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/jkomoros/Code/card-web/gulpfile.js from /Users/jkomoros/Code/card-web/node_modules/gulp/node_modules/gulp-cli/lib/versioned/^4.0.0/index.js not supported.
Instead change the require of gulpfile.js in /Users/jkomoros/Code/card-web/node_modules/gulp/node_modules/gulp-cli/lib/versioned/^4.0.0/index.js to a dynamic import() which is available in all CommonJS modules.
    at execute (/Users/jkomoros/Code/card-web/node_modules/gulp/node_modules/gulp-cli/lib/versioned/^4.0.0/index.js:36:18)
    at Liftoff.handleArguments (/Users/jkomoros/Code/card-web/node_modules/gulp/node_modules/gulp-cli/index.js:201:24)
    at Liftoff.execute (/Users/jkomoros/Code/card-web/node_modules/liftoff/index.js:201:12)
    at module.exports (/Users/jkomoros/Code/card-web/node_modules/flagged-respawn/index.js:51:3)
    at Liftoff.<anonymous> (/Users/jkomoros/Code/card-web/node_modules/liftoff/index.js:191:5)
    at /Users/jkomoros/Code/card-web/node_modules/liftoff/index.js:149:9
    at /Users/jkomoros/Code/card-web/node_modules/v8flags/index.js:138:14
    at /Users/jkomoros/Code/card-web/node_modules/v8flags/index.js:41:14
    at /Users/jkomoros/Code/card-web/node_modules/v8flags/index.js:53:7 {
  code: 'ERR_REQUIRE_ESM'
}
jkomoros commented 1 year ago