[英]Error installing create-react-app with npm
When I try to install create-react-app (or nodemon) globally or even within a project, I get the following error.当我尝试在全局甚至在项目中安装 create-react-app(或 nodemon)时,出现以下错误。 However, I can install other packages perfectly fine both globally and locally.
但是,我可以在全球和本地完美地安装其他软件包。 I think it has something to do with the fact that both create-react-app and nodemon are run from the terminal rather than used within a project's code.
我认为这与 create-react-app 和 nodemon 都是从终端运行而不是在项目代码中使用这一事实有关。
I have already tried reinstalling nodejs and opening the terminal as administrator, but that did not work.我已经尝试重新安装 nodejs 并以管理员身份打开终端,但这没有用。
$ npm i -D nodemon
npm ERR! path C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78\49\9aac8fdb9b898c6d95e47da44f0425e95568d85f83d82f7bae06293b0a03
npm ERR! code UNKNOWN
npm ERR! errno -4094
npm ERR! syscall open
npm ERR! UNKNOWN: unknown error, open 'C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78\49\9aac8fdb9b898c6d95e47da44f0425e95568d85f83d82f7bae06293b0a03'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Shivang\AppData\Roaming\npm-cache\_logs\2018-12-22T13_29_35_317Z-debug.log
UPDATE: When I ran npm cache clean --force, I got the following error更新:当我运行 npm cache clean --force 时,出现以下错误
$ npm cache clean --force
npm WARN using --force I sure hope you know what you are doing.
npm ERR! path C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78
npm ERR! code UNKNOWN
npm ERR! errno -4094
npm ERR! syscall unlink
npm ERR! UNKNOWN: unknown error, unlink 'C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Shivang\AppData\Roaming\npm-cache\_logs\2018-12-22T13_55_42_508Z-debug.log
When I try to install create-react-app (or nodemon) globally or even within a project, I get the following error.当我尝试在全局甚至在项目中安装create-react-app(或nodemon)时,出现以下错误。 However, I can install other packages perfectly fine both globally and locally.
但是,我可以在全局和本地完全安装其他软件包。 I think it has something to do with the fact that both create-react-app and nodemon are run from the terminal rather than used within a project's code.
我认为这与以下事实有关:create-react-app和nodemon均从终端运行,而不是在项目代码中使用。
I have already tried reinstalling nodejs and opening the terminal as administrator, but that did not work.我已经尝试过重新安装nodejs并以管理员身份打开终端,但这没有用。
$ npm i -D nodemon
npm ERR! path C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78\49\9aac8fdb9b898c6d95e47da44f0425e95568d85f83d82f7bae06293b0a03
npm ERR! code UNKNOWN
npm ERR! errno -4094
npm ERR! syscall open
npm ERR! UNKNOWN: unknown error, open 'C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78\49\9aac8fdb9b898c6d95e47da44f0425e95568d85f83d82f7bae06293b0a03'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Shivang\AppData\Roaming\npm-cache\_logs\2018-12-22T13_29_35_317Z-debug.log
UPDATE: When I ran npm cache clean --force, I got the following error更新:当我运行npm cache clean --force时,出现以下错误
$ npm cache clean --force
npm WARN using --force I sure hope you know what you are doing.
npm ERR! path C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78
npm ERR! code UNKNOWN
npm ERR! errno -4094
npm ERR! syscall unlink
npm ERR! UNKNOWN: unknown error, unlink 'C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Shivang\AppData\Roaming\npm-cache\_logs\2018-12-22T13_55_42_508Z-debug.log
When I try to install create-react-app (or nodemon) globally or even within a project, I get the following error.当我尝试在全局甚至在项目中安装create-react-app(或nodemon)时,出现以下错误。 However, I can install other packages perfectly fine both globally and locally.
但是,我可以在全局和本地完全安装其他软件包。 I think it has something to do with the fact that both create-react-app and nodemon are run from the terminal rather than used within a project's code.
我认为这与以下事实有关:create-react-app和nodemon均从终端运行,而不是在项目代码中使用。
I have already tried reinstalling nodejs and opening the terminal as administrator, but that did not work.我已经尝试过重新安装nodejs并以管理员身份打开终端,但这没有用。
$ npm i -D nodemon
npm ERR! path C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78\49\9aac8fdb9b898c6d95e47da44f0425e95568d85f83d82f7bae06293b0a03
npm ERR! code UNKNOWN
npm ERR! errno -4094
npm ERR! syscall open
npm ERR! UNKNOWN: unknown error, open 'C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78\49\9aac8fdb9b898c6d95e47da44f0425e95568d85f83d82f7bae06293b0a03'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Shivang\AppData\Roaming\npm-cache\_logs\2018-12-22T13_29_35_317Z-debug.log
UPDATE: When I ran npm cache clean --force, I got the following error更新:当我运行npm cache clean --force时,出现以下错误
$ npm cache clean --force
npm WARN using --force I sure hope you know what you are doing.
npm ERR! path C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78
npm ERR! code UNKNOWN
npm ERR! errno -4094
npm ERR! syscall unlink
npm ERR! UNKNOWN: unknown error, unlink 'C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Shivang\AppData\Roaming\npm-cache\_logs\2018-12-22T13_55_42_508Z-debug.log
When I try to install create-react-app (or nodemon) globally or even within a project, I get the following error.当我尝试在全局甚至在项目中安装create-react-app(或nodemon)时,出现以下错误。 However, I can install other packages perfectly fine both globally and locally.
但是,我可以在全局和本地完全安装其他软件包。 I think it has something to do with the fact that both create-react-app and nodemon are run from the terminal rather than used within a project's code.
我认为这与以下事实有关:create-react-app和nodemon均从终端运行,而不是在项目代码中使用。
I have already tried reinstalling nodejs and opening the terminal as administrator, but that did not work.我已经尝试过重新安装nodejs并以管理员身份打开终端,但这没有用。
$ npm i -D nodemon
npm ERR! path C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78\49\9aac8fdb9b898c6d95e47da44f0425e95568d85f83d82f7bae06293b0a03
npm ERR! code UNKNOWN
npm ERR! errno -4094
npm ERR! syscall open
npm ERR! UNKNOWN: unknown error, open 'C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78\49\9aac8fdb9b898c6d95e47da44f0425e95568d85f83d82f7bae06293b0a03'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Shivang\AppData\Roaming\npm-cache\_logs\2018-12-22T13_29_35_317Z-debug.log
UPDATE: When I ran npm cache clean --force, I got the following error更新:当我运行npm cache clean --force时,出现以下错误
$ npm cache clean --force
npm WARN using --force I sure hope you know what you are doing.
npm ERR! path C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78
npm ERR! code UNKNOWN
npm ERR! errno -4094
npm ERR! syscall unlink
npm ERR! UNKNOWN: unknown error, unlink 'C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Shivang\AppData\Roaming\npm-cache\_logs\2018-12-22T13_55_42_508Z-debug.log
Try running these commands.尝试运行这些命令。
npm cache clean --force
And then接着
sudo npm install -g create-react-app
This should work.这应该有效。
Use npx
command instead of npm
使用
npm
命令代替npx
Like this, First Mkdir appName mkdir appName
Secondly Cd into the app cd appName
像这样,首先 Mkdir appName
mkdir appName
其次 cd into the app cd appName
Thirdly run npx npx create-react-app./
第三次运行
npx create-react-app./
This how to run npx in react 18这是如何在 React 18 中运行 npx
Lol i just took the two previous answers and put them together.大声笑我只是把前面的两个答案放在一起。 So the solution is:
所以解决方案是:
npm cache clean --force (-g if first try doesnt work after npx). npm 缓存清理 --force(-g 如果第一次尝试在 npx 之后不起作用)。 then just use npx instead of npm.
然后只需使用 npx 而不是 npm。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.