Home > Enterprise >  node:internal/modules/cjs/loader:1056 throw err;
node:internal/modules/cjs/loader:1056 throw err;

Time:01-23

I am using Node.js v19.4.0.

When I run npx create-react-app MyApp to create react project in visual studio code editor I get the following error:

node:internal/modules/cjs/loader:1056
  throw err;
  ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1053:15)
    at Module._load (node:internal/modules/cjs/loader:898:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:84:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v19.4.0
node:internal/modules/cjs/loader:1056
  throw err;
  ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npx-cli.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1053:15)
    at Module._load (node:internal/modules/cjs/loader:898:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:84:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

CodePudding user response:

the first solution is to uninstall the node.js and npm and then reinstall them. or it might be because of an incorrect node_modules path. please check the path and make sure it is correct.

CodePudding user response:

First, try to clear npm cache:

npm cache clear --force or npm cache clean --force
  • then remove all node_modules from the application
  • remove the package-lock.json file from the application
  • Install packages again by using this command npm install
  • then start application using npm start

If the above solution will not work then, try to remove node.js and then re-install.

Hope this helps!

  • Related