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

16,821

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.

Share:
16,821
Himanshu Shekhar
Author by

Himanshu Shekhar

Updated on June 06, 2022

Comments

  • Himanshu Shekhar
    Himanshu Shekhar almost 2 years

    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?

  • Himanshu Shekhar
    Himanshu Shekhar almost 4 years
    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. stackoverflow.com/a/60320834/7026966
  • Dhamo
    Dhamo about 3 years
    Thanks, for me - upgrading latest node v fixes the issue
  • Glenn Ferrie
    Glenn Ferrie about 3 years
    +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