我第一次做react项目遇到了问题,我基本上是在做 npx create-react-app portfolio
这是终端的日志
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 '...w2l6C\nBZrjaE2TabX86o'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ITland\AppData\Roaming\npm-cache\_logs\2020-06-13T14_28_52_450Z-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 portfolio/ from C:\Users\ITland\Desktop\New folder (2)
有人知道是什么原因导致这个错误吗?
上面显示的日志信息表明,npx命令是在文件夹内运行的--。
C:/Users/ITland/Desktop/New folder (2)
在Windows上,npm命令有时会因为文件夹名中的空格或特殊字符而失败。
建议在运行npm的文件夹名中避免使用空格和特殊字符。
上述问题可以通过在以下文件中运行npm npx命令来解决
C:Users/ITland/Desktop/New_folder_2
尝试运行以下命令
npm cache clean --force
一旦成功,就可以尝试做你要找的事情。
用下面的方式试试。
npm cache clean --force
如果你是一个 windows
用户,尝试删除该文件夹中的所有文件。
C:/Users{{你的用户名}}/AppData/Roaming/npm-cache
然后...
npm cache verify
如果还不行,请尝试更新到最新的
npm i npm@latest -g