错误:
jane@ljj ~/WebstormProjects $ create-react-app test-react-app
Creating a new React app in /home/jane/WebstormProjects/test-react-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
npm ERR! Unexpected end of JSON input while parsing near '...0"},"_hasShrinkwrap":'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/jane/.npm/_logs/2018-06-09T06_14_46_082Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... package.json
Deleting test-react-app / from /home/jane/WebstormProjects
Done.
/home/jane/.npm/_logs/2018-06-09T06_14_46_082Z-debug.log文件的错误信息
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli '--save',
1 verbose cli '--save-exact',
1 verbose cli '--loglevel',
1 verbose cli 'error',
1 verbose cli 'react',
1 verbose cli 'react-dom',
1 verbose cli 'react-scripts' ]
2 info using npm@6.1.0
3 info using node@v10.4.0
4 verbose npm-session 316e959b45b2d620
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 304 https://registry.npm.taobao.org/react 439ms (from cache)
8 silly fetchPackageMetaData error for react@latest Unexpected end of JSON input while parsing near '...0"},"_hasShrinkwrap":'
9 http fetch GET 304 https://registry.npm.taobao.org/react-scripts 591ms (from cache)
10 silly pacote tag manifest for react-scripts@latest fetched in 613ms
11 http fetch GET 200 https://registry.npm.taobao.org/react-dom 786ms
12 silly pacote tag manifest for react-dom@latest fetched in 814ms
13 timing stage:rollbackFailedOptional Completed in 1ms
14 timing stage:runTopLevelLifecycles Completed in 2171ms
15 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...0"},"_hasShrinkwrap":'
15 verbose stack at JSON.parse (<anonymous>)
15 verbose stack at parseJson (/usr/local/lib/node_modules/npm/node_modules/json-parse-better-errors/index.js:7:17)
15 verbose stack at consumeBody.call.then.buffer (/usr/local/lib/node_modules/npm/node_modules/node-fetch-npm/src/body.js:96:50)
15 verbose stack at process._tickCallback (internal/process/next_tick.js:68:7)
16 verbose cwd /home/jane/WebstormProjects/test-react-app
17 verbose Linux 4.4.0-53-generic
18 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--save" "--save-exact" "--loglevel" "error" "react" "react-dom" "react-scripts"
19 verbose node v10.4.0
20 verbose npm v6.1.0
21 error Unexpected end of JSON input while parsing near '...0"},"_hasShrinkwrap":'
22 verbose exit [ 1, true ]
npm代理为淘宝的代理的时候就会发生这样的错误,将npm代理换回来就不报错了,具体原因不详,但是亲证可行
npm config set registry http://registry.cnpmjs.org