[英]“npm ERR! unexpected end of JSON input near” while creating a new react app
[enter image description here][1] npm [在此处输入图片描述][1] npm
I am trying for so many times to create a app in react but every time the CMD showing an ERR!我尝试了很多次来创建一个反应应用程序,但每次 CMD 都显示 ERR!
here is code: Microsoft Windows [Version 10.0.18363.476] (c) 2019 Microsoft Corporation.这是代码:Microsoft Windows [版本 10.0.18363.476] (c) 2019 Microsoft Corporation。 All rights reserved.版权所有。
C:\Users\Sumit>E: The system cannot find the drive specified. C:\Users\Sumit>E:系统找不到指定的驱动器。
C:\Users\Sumit>D: C:\用户\Sumit>D:
D:>React js 'React' is not recognized as an internal or external command, operable program or batch file. D:>React js 'React' 不是内部或外部命令、可运行程序或批处理文件。
D:>react js 'react' is not recognized as an internal or external command, operable program or batch file. D:>react js 'react' 不是内部或外部命令、可运行程序或批处理文件。
D:>React js 'React' is not recognized as an internal or external command, operable program or batch file. D:>React js 'React' 不是内部或外部命令、可运行程序或批处理文件。
D:>create-react-app my_react D:>create-react-app my_react
Creating a new React app in D:\my_react.在 D:\my_react 中创建一个新的 React 应用程序。
Installing packages.安装软件包。 This might take a couple of minutes.这可能需要几分钟。 Installing react, react-dom, and react-scripts...安装 react、react-dom 和 react-scripts...
npm ERR! npm 错误! Response timeout while trying to fetch https://registry.npmjs.org/react (over 30000ms)尝试获取https://registry.npmjs.org/react时响应超时(超过 30000 毫秒)
npm ERR: A complete log of this run can be found in: npm ERR. npm ERR:此运行的完整日志可在以下位置找到:npm ERR。 C:\Users\Sumit\AppData\Roaming\npm-cache_logs\2020-06-01T14_33_43_496Z-debug.log C:\Users\Sumit\AppData\Roaming\npm-cache_logs\2020-06-01T14_33_43_496Z-debug.log
Aborting installation.中止安装。 npm install --save --save-exact --loglevel error react react-dom react-scripts has failed. npm install --save --save-exact --loglevel error react-dom react-scripts has failed。
Deleting generated file... package.json Deleting my_react / from D:\ Done.正在删除生成的文件... package.json 从 D:\ 删除 my_react / 完成。
D:>create-react-app my-react-app D:>create-react-app 我的-react-app
Creating a new React app in D:\my-react-app.在 D:\my-react-app 中创建一个新的 React 应用程序。
Installing packages.安装软件包。 This might take a couple of minutes.这可能需要几分钟。 Installing react, react-dom, and react-scripts...安装 react、react-dom 和 react-scripts...
npm ERR. npm 错误。 Unexpected end of JSON input while parsing near '...Y3hEcJW8se9P4K6+GYGu9'在“...Y3hEcJW8se9P4K6+GYGu9”附近解析时 JSON 输入意外结束
npm ERR: A complete log of this run can be found in: npm ERR. npm ERR:此运行的完整日志可在以下位置找到:npm ERR。 C:\Users\Sumit\AppData\Roaming\npm-cache_logs\2020-06-01T14_34_57_334Z-debug.log C:\Users\Sumit\AppData\Roaming\npm-cache_logs\2020-06-01T14_34_57_334Z-debug.log
Aborting installation.中止安装。 npm install --save --save-exact --loglevel error react react-dom react-scripts has failed. npm install --save --save-exact --loglevel error react-dom react-scripts has failed。
Deleting generated file... package.json Deleting my-react-app / from D:\ Done.正在删除生成的文件... package.json 从 D:\ 删除 my-react-app / 完成。
D:>create-react-app new-react D:>create-react-app 新反应
Creating a new React app in D:\new-react.在 D:\new-react 中创建一个新的 React 应用程序。
Installing packages.安装软件包。 This might take a couple of minutes.这可能需要几分钟。 Installing react, react-dom, and react-scripts...安装 react、react-dom 和 react-scripts...
npm ERR. npm 错误。 Unexpected end of JSON input while parsing near '...gAAwSQP/RpJCkm/rgw8jt'在“...gAAwSQP/RpJCkm/rgw8jt”附近解析时 JSON 输入意外结束
npm ERR: A complete log of this run can be found in: npm ERR. npm ERR:此运行的完整日志可在以下位置找到:npm ERR。 C:\Users\Sumit\AppData\Roaming\npm-cache_logs\2020-06-01T14_38_28_735Z-debug.log C:\Users\Sumit\AppData\Roaming\npm-cache_logs\2020-06-01T14_38_28_735Z-debug.log
Aborting installation.中止安装。 npm install --save --save-exact --loglevel error react react-dom react-scripts has failed. npm install --save --save-exact --loglevel error react-dom react-scripts has failed。
Deleting generated file... package.json Deleting new-react / from D:\ Done.正在删除生成的文件... package.json 从 D:\ 删除 new-react / 完成。
D:>npm create-react-app my-react-aplication D:>npm create-react-app my-react-aplication
Usage: npm用途:npm
where is one of: access, adduser, audit, bin, bugs, c, cache, ci, cit, clean-install, clean-install-test, completion, config, create, ddp, dedupe, deprecate, dist-tag, docs, doctor, edit, explore, fund, get, help, help-search, hook, i, init, install, install-ci-test, install-test, it, link, list, ln, login, logout, ls, org, outdated, owner, pack, ping, prefix, profile, prune, publish, rb, rebuild, repo, restart, root, run, run-script, s, se, search, set, shrinkwrap, star, stars, start, stop, t, team, test, token, tst, un, uninstall, unpublish, unstar, up, update, v, version, view, whoami其中之一是:访问、添加用户、审计、bin、错误、c、缓存、ci、cit、全新安装、全新安装测试、完成、配置、创建、ddp、重复数据删除、弃用、dist-tag、文档, 医生, 编辑, 探索, 基金, 获取, 帮助, 帮助搜索, 钩子, 我, 初始化, 安装, install-ci-test, install-test, 它, 链接, 列表, ln, 登录, 注销, ls, org ,过时,所有者,包,ping,前缀,配置文件,修剪,发布,rb,重建,回购,重新启动,根,运行,运行脚本,s,se,搜索,设置,收缩包装,星,星,开始,停止, t, 团队, 测试, 令牌, tst, un, 卸载, unpublish, unstar, up, update, v, version, view, whoami
npm -h quick help on npm -l display full usage info npm help search for help on npm help npm involved overview npm -h quick help on npm -l display full usage info npm help search for help on npm help npm involved overview
Specify configs in the ini-formatted file: C:\Users\Sumit.npmrc or on the command line via: npm --key value Config info can be viewed via: npm help config在 ini 格式的文件中指定配置:C:\Users\Sumit.npmrc 或在命令行上通过:npm --key value 可以通过以下方式查看配置信息:ZBB30E85411B445DF41296帮助config726
npm@6.14.4 C:\Program Files\nodejs\node_modules\npm npm@6.14.4 C:\Program Files\nodejs\node_modules\npm
D:>npx create-react-app my-react D:>npx create-react-app 我的反应
Creating a new React app in D:\my-react.在 D:\my-react 中创建一个新的 React 应用程序。
Installing packages.安装软件包。 This might take a couple of minutes.这可能需要几分钟。 Installing react, react-dom, and react-scripts...安装 react、react-dom 和 react-scripts...
npm ERR. npm 错误。 Unexpected end of JSON input while parsing near '...gAAwSQP/RpJCkm/rgw8jt'在“...gAAwSQP/RpJCkm/rgw8jt”附近解析时 JSON 输入意外结束
npm ERR: A complete log of this run can be found in: npm ERR. npm ERR:此运行的完整日志可在以下位置找到:npm ERR。 C:\Users\Sumit\AppData\Roaming\npm-cache_logs\2020-06-01T14_54_02_126Z-debug.log C:\Users\Sumit\AppData\Roaming\npm-cache_logs\2020-06-01T14_54_02_126Z-debug.log
Aborting installation.中止安装。 npm install --save --save-exact --loglevel error react react-dom react-scripts has failed. npm install --save --save-exact --loglevel error react-dom react-scripts has failed。
Deleting generated file... package.json Deleting my-react / from D:\ Done.正在删除生成的文件... package.json 从 D:\ 删除 my-react / 完成。
D:> D:>
There are two things that you can do that might possibily help you resolve the issue you are facing.您可以做两件事,可能会帮助您解决所面临的问题。
timeout=6000
You can find the.npmrc file at the path:您可以在以下路径中找到 .npmrc 文件:
C:\Program Files\nodejs\node_modules\npm
npm install -g npm
Hope this helps!!希望这可以帮助!!
if you didn't install npm in general mode, it should better you do it with this comment in the root with the command如果您没有在一般模式下安装 npm,最好使用命令在根目录中使用此注释执行此操作npm install -g
, or if you did it before you need to update it with the command npm update [-g]
npm install -g
,或者如果您在需要更新它之前使用命令npm update [-g]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.