5

Executed yarn install in my project folder and got below error.

internal/modules/cjs/loader.js:800
throw err;
^
Error: Cannot find module 'ts-node/register'
Require stack:
- internal/preload
?[90m    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797
:15)?[39m
?[90m    at Function.Module._load (internal/modules/cjs/loader.js:690:27)?[39m
?[90m    at Module.require (internal/modules/cjs/loader.js:852:19)?[39m
?[90m    at Module._preloadModules (internal/modules/cjs/loader.js:1147:12)?[39m
?[90m    at loadPreloadModules (internal/bootstrap/pre_execution.js:443:5)?[39m
?[90m    at prepareMainThreadExecution (internal/bootstrap/pre_execution.js:62:3
)?[39m
?[90m    at internal/main/run_main_module.js:7:1?[39m {
code: ?[32m'MODULE_NOT_FOUND'?[39m,
requireStack: [ ?[32m'internal/preload'?[39m ]
}

Removed node_module, yarn.lock and node-cache. But no success.

This error is not project specific. If i run yarn, node or npm anywhere in my system I'm getting above error. Is my node and yarn package corrupted?

CoryCoolguy
  • 1,065
  • 8
  • 18
Himanshu Shekhar
  • 1,196
  • 1
  • 16
  • 35

2 Answers2

1

Solved Issue by checking NODE_OPTIONS

Run echo %NODE_OPTIONS% and got ts-node/register.

So, to remove ts-node/register run setx NODE_OPTIONS ""

After this node,npm and yarn are working properly.

Himanshu Shekhar
  • 1,196
  • 1
  • 16
  • 35
-1

Try following command:

Step 1 : remove node_modules and files and package-lock.json

Then run following command to install dependencies:

Step 2: $ rm -rf node_modules package-lock.json && npm install && npm start

Finally, run your package by following command:

npm start

Hoppo
  • 1,130
  • 1
  • 13
  • 32
hmze ahmd
  • 9
  • 1
  • This issue is not project specific. I tried all things which you mentioned in your answer. I resolved this issue and also provided the solution. https://stackoverflow.com/a/60320834/7026966 – Himanshu Shekhar Jun 28 '20 at 17:49
  • +1 in my case it was project specific and this fix helped me. my issue occurred after Windows 10 updates on insider build on 3/22/21 – Glenn Ferrie Mar 23 '21 at 20:36