简体   繁体   中英

How to solve error: Cannot find module 'json-parse-helpfulerror'

In Windows, I tried to create a new application form of this site: https://facebook.github.io/react/docs/installation.html

First, I installed Node.js v8.2.1 and when I execute npm install -g create-react-app , I get the following error:

npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'json-parse-helpfulerror'

npm-debug.log:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\mushou8\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   '-g',
1 verbose cli   'create-react-app' ]
2 info using npm@5.2.0
3 info using node@v6.11.2
4 verbose stack Error: Cannot find module 'json-parse-helpfulerror'
4 verbose stack     at Function.Module._resolveFilename (module.js:469:15)
4 verbose stack     at Function.Module._load (module.js:417:25)
4 verbose stack     at Module.require (module.js:497:17)
4 verbose stack     at require (internal/module.js:20:19)
4 verbose stack     at Object.<anonymous> (C:\Users\mushou8\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:12:16)
4 verbose stack     at Module._compile (module.js:570:32)
4 verbose stack     at Object.Module._extensions..js (module.js:579:10)
4 verbose stack     at Module.load (module.js:487:32)
4 verbose stack     at tryModuleLoad (module.js:446:12)
4 verbose stack     at Function.Module._load (module.js:438:3)
5 verbose cwd C:\Users\mushou8
6 verbose Windows_NT 6.1.7601
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\mushou8\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "create-react-app"
8 verbose node v6.11.2
9 verbose npm  v5.2.0
10 error code MODULE_NOT_FOUND
11 error Cannot find module 'json-parse-helpfulerror'
12 verbose exit [ 1, true ]

在目录文件夹中,发出以下命令:

npm update

Remove npm and reinstall it

And run:

sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*

Seeing what is requested in the Users folder, it seems that it should be installed as a global package.

Check and install each required package.

npm i -g json-parse-helpfulerror
  1. You must uninstall nodejs and npm packages.
  2. after first, you must install npm.
  3. and you should install "npm install --save json-parse-better-errors"
  4. Finally you can run your project

https://www.npmjs.com/package/json-parse-better-errors

I fixed it by removing the node_modules folder and reinstalling it again. To remove the folder, go to your project folder and run $ rm -rf node_modules and then reinstall your packages using your preferred package manager, either npm i or yarn install .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM