Cannot find module 'ts-node/register' in global
See original GitHub issueIt work on locally install, but not work on globally install
npm install ts-node -g
npm install typescript -g
package.json
{
...
scripts: {
....
"test": "mocha --require ts-node/register test/*.ts
}
}
when run npm run test, it throwing:
Error: Cannot find module 'ts-node/register'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at requires.forEach.mod (/home/s97712/extdata/sqlbind.js/node_modules/mocha/bin/_mocha:511:3)
at Array.forEach (<anonymous>)
at Object.<anonymous> (/home/s97712/extdata/sqlbind.js/node_modules/mocha/bin/_mocha:510:10)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Cannot find module 'ts-node/register'
This solution doesn't need you to install ts-node globally. And it works cross platform and for everyone. Share.
Read more >Cannot find module 'ts-node/register' in VS Code Debug
I have install ts-node globally instead of making package dependency. I tried to link local package to the global one and that was...
Read more >Cannot find module 'ts-node/register' Error in TypeScript
To solve the error "Cannot find module 'ts-node/register'", install ts-node and typescript as development dependencies by running npm install --save-dev ...
Read more >ts-node
This error is thrown by node when a module is require() d, but node believes it should execute as native ESM. This can...
Read more >ts-node Run Configuration error
Error: Cannot find module 'ts-node/register' ... fine if I run it from iTerm with the globally installed ts-node but not within IntelliJ.
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
@lukepighetti Probably an obvious question, but did you do an
npm install? That’s a normal node.js error with being unable to resolve the module from your working directory. E.g., if you dols node_modules/ts-node/registerdo you see anindex.jsfile?I also have this error, and I have the dependencies installed both globally and locally, but I still get this:
After this I notice the path in the
--requireflag and I modify it as:env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha --require ./node_modules/ts-node/register 'test/**/*.ts'"With the
./node_modules/..I manage to solve it! I hope that it can help