我对npm有问题。我尝试了:npx create-react-app my-app
,但是返回了错误。
我的命令提示符输出:
c:\Users\sysli\Desktop\reactprojects>npx create-react-app my-app
npx: installed 91 in 34.825s
Creating a new React app in c:\Users\sysli\Desktop\reactprojects\my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! Unexpected end of JSON input while parsing near '..."jscs":"~3.0.7","moch'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\sysli\AppData\Roaming\npm-cache\_logs\2019-12-26T21_21_02_198Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... package.json
Deleting my-app/ from c:\Users\sysli\Desktop\reactprojects
Done.
答案 0 :(得分:0)
更新npm后可以重试吗?
npm install -g npm
请注意,此命令将删除您当前的npm版本。确保使用 sudo npm如果在Mac上则安装-g npm。
答案 1 :(得分:0)
更新计算机上的npm( Prasool建议):
sudo npm i -g npm
如果无法正常使用,请使用
npm cache clean --force
,因为它似乎适用于此处和GitHub。 :)
祝您编码愉快!