internal/modules/cjs/loader.js:800 throw err

Himanshu Shekhar picture Himanshu Shekhar · Feb 20, 2020 · Viewed 11.7k times · Source

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?

Answer

Himanshu Shekhar picture Himanshu Shekhar · Feb 20, 2020

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.