我使用npm在Node JS上安装了最新版本,但是无法运行create-react-app。 发生以下问题:
Creating a new React app in C:\wamp64\www\bob.
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 '....tgz"}},"2.3.4":{"nam'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ivana\AppData\Roaming\npm-cache_logs\2019-02-26T21_21_48_727Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... package.json
Deleting bob/ from C:\wamp64\www
Done.
版本:
Node v10.15.1
npm 6.7.0
有人可以帮忙吗?
运行npm缓存清理后--force
另一个错误发生:
$ create-react-app bob
Creating a new React app in C:\Users\Ivana\bob.
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 '...,"@babel/plugin-synta'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ivana\AppData\Roaming\npm-cache\_logs\2019-02-27T09_18_28_856Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... package.json
Deleting bob/ from C:\Users\Ivana
Done.
答案 0 :(得分:1)
答案 1 :(得分:0)
来自https://github.com/facebook/create-react-app
npx create-react-app my-app
(npx随附npm 5.2及更高版本)
但是你用过
create-react-app my-app
如果使用npm 5.1或更早版本,则不能使用npx。相反,请全局安装create-react-app:
npm install -g create-react-app
现在您可以运行:
create-react-app my-app
答案 2 :(得分:0)
我能够解决这个问题,
运行
npm cache clean --force
然后
npm create-react-app my-app
答案 3 :(得分:0)
经过几次搜索,我发现了这一点:
如果您之前已通过npm install -g全局安装了create-react-app create-react-app,建议您使用npm uninstall -g卸载软件包 create-react-app,以确保npx始终使用最新版本。
因此,如果您使用以下方式安装了create-react-app
npm -g install create-react-app
只要运行:
npm -g uninstall create-react-app
npx create-react-app
它应该完成工作