开发者问题收集

为什么我在尝试安装 React 应用时不断收到错误

2020-04-18
72

这是我第一次尝试 React,一遍又一遍地看到相同的错误让我很沮丧。我分别尝试了这三个代码
npx create-react-app myapp
npm init react-app myapp
npm install -g create-react-app 然后 create-react-app myapp

所有这些都给了我:

npm ERR! Unexpected end of JSON input while parsing near '...:"^5.0.0 || ^6.0.0"},'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\{hiddenForPrivacyReasons}\AppData\Roaming\npm-cache\_logs\2020-04-18T14_12_44_513Z-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 D:\{hiddenForPrivacyReasons}\codes\app
Done.

救命!!!

1个回答

你不需要 react-app 和其他脚本

只需:

npx create-react-app my-app
cd my-app
npm start

参考: create-react-app 文档>

keikai
2020-04-18