fix: custom-checks script from package.json does not work
See original GitHub issueDescription
Running yarn custom-checks
returns an error:
TypeError [ERR_INVALID_MODULE_SPECIFIER]: Invalid module "file:///Users/youngonelee/cactus/tools/custom-checks/run-custom-checks.ts"
at new NodeError (node:internal/errors:371:5)
at ESMLoader.load (node:internal/modules/esm/loader:324:13)
at async ESMLoader.moduleProvider (node:internal/modules/esm/loader:230:47)
at async link (node:internal/modules/esm/module_job:67:21) {
code: 'ERR_INVALID_MODULE_SPECIFIER'
}
1: 0x101c462b5 node::Abort() [/usr/local/bin/node]
2: 0x101c4797c node::errors::TriggerUncaughtException(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/bin/node]
3: 0x101e25368 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) [/usr/local/bin/node]
4: 0x101e24e36 v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/usr/local/bin/node]
5: 0x101e2456f v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
6: 0x102682379 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit [/usr/local/bin/node]
7: 0x102614d6a Builtins_InterpreterEntryTrampoline [/usr/local/bin/node]
8: 0x1026445c7 Builtins_AsyncFunctionAwaitRejectClosure [/usr/local/bin/node]
error Command failed with signal "SIGABRT".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
node.js - package.json custom scripts not being executed
What you can try is running npm config get ignore-scripts in your termenal. If it returns true run npm config set ignore-scripts false...
Read more >[BUG] ``npm run`` inside package.json scripts are not aware of ...
[BUG] npm run inside package.json scripts are not aware of workspace context # ... npm WARN config This command does not support workspaces....
Read more >npm Scripts: Tips Everyone Should Know - Corgibytes
You specify your scripts within the scripts attribute of the main object in package.json and then run it using npm run <name> ....
Read more >Creating a package.json file - npm Docs
Running a CLI questionnaire · On the command line, navigate to the root directory of your package. cd /path/to/package · Run the following...
Read more >package.json Quick Start Guide | phoenixNAP KB
Every npm package and Node.js project has a package.json file with ... a major release informs developers that a package does not work...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@petermetz As for this issue, the first solution that I have found that results to a non-error one, is reverting back to older node version.
(https://stackoverflow.com/questions/63807613/running-node-with-loader-ts-node-esm-js-requires-imports-to-have-the-js-extensi) Based on this discussion, they used v14.15.0 and it fixed their problem. I have tried using the same version and the result was a success.
However, we are using v16.13.1 for cactus right now so we just put this solution on hold and looked for more solution to make it work on v16.
I also tried adding “type”: “module” and changing “module”: “ESNext” into “module”: “commonjs” but the result is still an error. (https://github.com/TypeStrong/ts-node/issues/1171)
(https://github.com/egoist/esbuild-register/issues/22) According to this, they used v16.4.1. I tried it and it resulted to a success.
(https://github.com/TypeStrong/ts-node/pull/1522) (https://github.com/nodejs/node/pull/40504) In here, the version checks for v16 are working up until v16.12.0. Something closer to the current one we are using which is v16.13.1. I have tried v16.12.0 and it resulted to an error.
However, v16.11.0 resulted to a success. The closest to v16.13.0 that is a success custom-checks.
Is it possible to bump down the node version from v16.13.1 to v16.11.0 ? Thank you.
@ruzell22 I took a stab at it just now and managed to get it to work with (seemingly) all v16.. versions by upgrading the
ts-node
dependency from"10.2.0"
to"10.7.0"
. Please update your PR to include that as the fix instead of changing the NodeJS versions. This way people won’t have to wonder what’s going wrong if they happen to be on a NodeJS 16 minor version that the old version of ts-node does not work with.Make sure to
yarn
after updating the root package.json file with the new dependency version. This will trigger the update to the yarn.lock file as well.