我正在尝试使用npx创建反应应用程序,但出现以下错误:
npm错误!在解析附近时,Json输入意外结束 '... eact-app /-// create-rea'
npm错误!可以在以下位置找到该运行的完整日志:npm ERR! C:\ Users \ dp \ AppData \ Roaming \ npm-cache_logs \ 2018-12-06T18-42-56-293Z-debug.log
安装create-react-app @ latest失败,代码为1 **
和错误的日志文件在这里...!
如何摆脱这种麻烦?
0信息,如果以ok 1冗长的cli结尾['C:\ Program Files \ nodejs \ node.exe',
1个详细cli
'C:\ Users \ dp \ AppData \ Roaming \ npm \ node_modules \ npm \ bin \ npm-cli.js',1个详细的cli'install',
1个详细的cli'create-react-app @ latest',
1详细的cli'--global',
1个详细的cli'--prefix',
1个详细cli
'C:\ Users \ dp \ AppData \ Roaming \ npm-cache \ _npx \ 3588',1个详细的cli'--loglevel',
1冗长的cli'error',
1个详细的cli'--json']
使用npm@6.4.1的2条信息
使用node@v10.13.0的3条信息
4个详细的npm-session 7862701600d4f4ce
5个愚蠢的安装loadCurrentTree
6愚蠢地安装readGlobalPackageData
7 http获取GET 304
https://registry.npmjs.org/create-react-app 872ms(来自缓存)
create-react-app @ latest的8个愚蠢的fetchPackageMetaData错误 解析附近时JSON输入意外结束 '... eact-app /-// create-rea'
9个计时阶段:rollbackFailed可选在4毫秒内完成10个计时 stage:runTopLevelLifecycles在1693ms中完成11详细堆栈 SyntaxError:解析附近时,JSON输入意外结束 '... eact-app /-// create-rea'JSON.parse上的11个详细堆栈 ()parseJson的11个详细堆栈 (C:\ Users \ dp \ AppData \ Roaming \ npm \ node_modules \ npm \ node_modules \ json-parse-Better-errors \ index.js:7:17) 消耗的11个详细堆栈stack.call.then.buffer (C:\ Users \ dp \ AppData \ Roaming \ npm \ node_modules \ npm \ node_modules \ node-fetch-npm \ src \ body.js:96:50) process._tickCallback上的11个详细堆栈 (内部/进程/next_tick.js:68:7)12详细的CWD C:\ Users \ dp 13 详细Windows_NT 6.3.9600 14详细argv“ C:\ Program Files \ nodejs \ node.exe” “ C:\ Users \ dp \ AppData \ Roaming \ npm \ node_modules \ npm \ bin \ npm-cli.js” “安装”“ create-react-app @ latest”“ --global”“ --prefix” “ C:\ Users \ dp \ AppData \ Roaming \ npm-cache \ _npx \ 3588”“ --loglevel” “错误”“ --json” 15详细节点v10.13.0 16详细npm v6.4.1 17 错误解析附近时JSON输入意外结束 '... eact-app /-// create-rea'18详细出口[1,true]
答案 0 :(得分:17)
我遇到了同样的问题“代码为7的create-react-app @ latest安装失败” 用这个。它对我有用。
npm install -g create-react-app
npx create-react-app my-app
cd my-app
npm start
有关更多参考,请访问:https://www.techomoro.com/how-to-install-and-setup-a-react-app-on-windows-10/
答案 1 :(得分:8)
首先,通过在终端中键入以下内容来清除缓存:
npm cache clean --force
然后按照以下these步骤或键入以下命令升级您的npm版本:
npm install -g npm@next
现在转到Windows设置的“程序和功能”中的“ NodeJS” ,然后修复。
重新启动终端,然后输入:
npx create-react-app my-app
这有望解决您的问题。
答案 2 :(得分:1)
要解决此问题,请运行以下命令
npm初始化
然后
npm install create-react-app
npx create-react-app myapp
答案 3 :(得分:1)
清理npm缓存:
npm cache clean --force
然后重试
答案 4 :(得分:1)
存在错误,因为您的用户 pc 名称包含空格, 您可以使用此代码解决此问题:
> npm config set cache "C:\Users\mycomputer~1name\AppData\Roaming\npm-cache" --global
答案 5 :(得分:1)
答案 6 :(得分:1)
在您的防病毒白名单中,节点软件
在我看来,大家好,请检查您的系统是否正在运行任何防病毒软件并更具体地阻止 node.exe(ByteFence 反恶意软件)
就我而言,它阻塞了节点系统调用
我从系统托盘中的隐藏图标退出它,它对我来说很好
当你这样做时 => npm start
答案 7 :(得分:1)
NPM -代表 Node Package Manager 。 NPM是世界上最大的软件注册中心。来自各大洲的开源开发人员都使用npm共享和借用软件包,许多组织也使用npm来管理私人开发。
NPX -用于执行遵循此提要的npm软件包二进制文件:
npx [options] <command>[@version] [command-arg]...
其中<command>
从本地node_modules/.bin
或从中央缓存执行,安装运行所需的所有软件包。
解决方案:使用npx create-react-app my-app
在系统中安装create-react-app
。
上面的示例将在命令运行的路径内生成一个react
应用样板。npx
将检查<command>
或本地中是否存在$PATH
项目二进制文件,然后执行它。
点击以下链接以获取参考和帮助:
答案 8 :(得分:0)
npm uninstall -g create-react-app
npx create-react-app my-app
您不需要全局安装create-react-app软件包。 'npx'已经安装了最新版本。
答案 9 :(得分:0)
试试这个:
npm cache clean --force
npx create-react-app myapp
它对我有用。
答案 10 :(得分:0)
npm cache clean --force
npx create-react-app project_name --template all
cd project_name
npm 启动
答案 11 :(得分:0)
这对我有用: 因为我有网络问题
npx create-react-app <app name> -timeout=60000
答案 12 :(得分:0)
这对我有用。
npm cache clear --force
npm init -y
npx create-react-app my-app
答案 13 :(得分:0)
出现问题的原因有很多。
如果您的防病毒软件是您的问题,请在您运行命令期间禁用它。
无论是什么原因 npx create-react-app 无法在您的机器上运行,请依次运行以下命令:
npm cache clean --force
npx create-react-app my-app
如果这对你有用,请告诉我
答案 14 :(得分:0)
我尝试了一切,但无济于事。
然后,我重新启动了笔记本电脑,当我尝试npm init
之后再尝试npm install create-react-app
时,我收到了Avast潜在有害文件警报,但是还可以,我确认了。
create-react-app
的尝试失败了,但是当我再次尝试时,它成功了。
防火墙等可能会阻止节点执行功能,因此为什么会抛出从未称为错误的callback()。
答案 15 :(得分:0)
有时是由于互联网速度较慢而发生的。 试试这个。
npx create-react-app <app name> -timeout=60000
默认超时= 30000(30秒)。如果需要,可以增加超时时间。
答案 16 :(得分:0)
在防病毒白名单中,该节点软件
在我看来,大家好,检查系统是否有防病毒软件 运行并阻止node.exe ,更具体地说,是(ByteFence反恶意软件)
在我的情况下,它阻止了节点系统调用
我从系统托盘中的隐藏图标退出了 ,它对我来说很好 < / p>
什么时候做
npm开始
答案 17 :(得分:0)
以管理员身份运行Windows PowerShell,然后输入以下内容:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
答案 18 :(得分:0)
当我运行common npx crate-react-app 我遇到此错误该怎么办?请
:找不到内存文件/ nodejs / npm:3:/ mnt / c / Program Files / nodejs / npm: :找不到ram文件/ nodejs / npm:5:/ mnt / c / Program Files / nodejs / npm: / mnt / c / Program Files / nodejs / npm:6:/ mnt / c / Program Files / nodejs / npm:语法错误:单词意外(期望为“ in”)
答案 19 :(得分:0)
这对我有用!
首先,您需要通过
创建package.json文件npm init
然后
npx create-react-app myapp
答案 20 :(得分:0)
安装节点版本10.15.3 https://nodejs.org/download/release/v10.15.3/
OR
从您的系统中删除nvm,这引起了我很多问题。删除nvm之后,我什至可以在节点的版本12中运行它
答案 21 :(得分:0)
当我使用来自官方资源https://reactjs.org/docs/create-a-new-react-app.html#create-react-app的命令时,在创建react项目时遇到了同样的问题
npx create-react-app my-app
cd my-app
npm start
以上命令在我的Windows上不起作用。 即使在我的机器上我也有Node> = 6 and npm> = 5.2 它无法打开localhost:3000 然后我用了这个命令
npm install -g create-react-app
create-react-app my-app-name
cd my-app-name
npm start
了解到
答案 22 :(得分:-1)
如果无法创建该应用,请尝试以32位重新安装nodeJS并尝试。
答案 23 :(得分:-1)
这应该可以解决问题。