[英]npx create-react-app myapp command throwning error
I wanted to create an app in react .我想在 react 中创建一个应用程序。 I have installed the latest Node js when I am running the command I am getting error
我在运行命令时安装了最新的 Node js 我收到错误
PS C:\\Users\\Kumar Sanket\\Desktop\\React&Redux> npx create-react-app myapp Error: EEXIST: file already exists, mkdir 'C:\\Users\\Kumar' TypeError: Cannot read property 'get' of undefined at errorHandler (C:\\Program Files\\nodejs\\node_modules\\npm\\lib\\utils\\error-handler.js:205:18) at C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js:78:20 at cb (C:\\Program Files\\nodejs\\node_modules\\npm\\lib\\npm.js:228:22) at C:\\Program Files\\nodejs\\node_modules\\npm\\lib\\npm.js:266:24 at C:\\Program Files\\nodejs\\node_modules\\npm\\lib\\config\\core.js:83:7 at Array.forEach () at C:\\Program Files\\nodejs\\node_modules\\npm\\lib\\config\\core.js:82:13 at f (C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\once\\once.js:25:25) at afterExtras (C:\\Program Files\\nodejs\\node_modules\\npm\\lib\\config\\core.js:173:20) at C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\mkdirp\\index.js:47:53 C:\\Program Files\\nodejs\\node_modules\\npm\\lib\\utils\\error-handler.js:205 if (npm.config.get('json')) { ^ PS C:\\Users\\Kumar Sanket\\Desktop\\React&Redux> npx create-react-app myapp 错误:EEXIST:文件已经存在,mkdir 'C:\\Users\\Kumar' TypeError:无法读取 errorHandler 处未定义的属性“get”( C:\\Program Files\\nodejs\\node_modules\\npm\\lib\\utils\\error-handler.js:205:18) 在 C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js:78:20在 cb (C:\\Program Files\\nodejs\\node_modules\\npm\\lib\\npm.js:228:22) 在 C:\\Program Files\\nodejs\\node_modules\\npm\\lib\\npm.js:266:24 在 C: \\Program Files\\nodejs\\node_modules\\npm\\lib\\config\\core.js:83:7 at Array.forEach () at C:\\Program Files\\nodejs\\node_modules\\npm\\lib\\config\\core.js:82: 13 在 f (C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\once\\once.js:25:25) at afterExtras (C:\\Program Files\\nodejs\\node_modules\\npm\\lib\\config\\core.js :173:20) 在 C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\mkdirp\\index.js:47:53 C:\\Program Files\\nodejs\\node_modules\\npm\\lib\\utils\\error-handler.js :205 如果 (npm.config.get('json')) { ^
TypeError: Cannot read property 'get' of undefined at process.errorHandler (C:\\Program Files\\nodejs\\node_modules\\npm\\lib\\utils\\error-handler.js:205:18) at process.emit (events.js:189:13) at process._fatalException (internal/bootstrap/node.js:496:27) Install for create-react-app@latest failed with c类型错误:无法读取 process.errorHandler (C:\\Program Files\\nodejs\\node_modules\\npm\\lib\\utils\\error-handler.js:205:18) at process.emit (events.js: 189:13) 在 process._fatalException (internal/bootstrap/node.js:496:27) 安装 create-react-app@latest 失败,c
Today I encountered a similar issue with npx create-react-app my-app (mkdir failed).今天我在npx create-react-app my-app (mkdir failed) 中遇到了类似的问题。
Reason for my error我的错误的原因
I had space in my user name folder(ex: Abc Xyz) and thus "npx" couldn't refer to it correctly (It only read Abc, and not Xyz).我的用户名文件夹中有空间(例如:Abc Xyz),因此“npx”无法正确引用它(它只读取 Abc,而不读取 Xyz)。
I am using VS Code for React, and it didn't had the permission to create new directory我正在使用 VS Code for React,但它没有创建新目录的权限
How I fixed it我是如何修复它的
Opened VS Code with Administrator rights.(fixed permission issue)以管理员权限打开 VS Code。(修复权限问题)
Instead of using "npx" I tried the following:我没有使用“npx”,而是尝试了以下操作:
--> npm install -g create-react-app --> npm install -g create-react-app
--> create-react-app my-app --> create-react-app my-app
And that got executed successfully.然后就成功执行了。
Hope this helps.希望这可以帮助。
The problem is the space in the username.问题是用户名中的空格。 I use Windows 10 and I solved it by changing the path of npm cache folder in this way:
我使用 Windows 10,我通过以这种方式更改 npm 缓存文件夹的路径来解决它:
npm config get cache
to check the value of property cache in your config filenpm config get cache
检查配置文件中的属性缓存值C:\\Users\\Andrea R\\AppData\\Roaming\\npm-cache
C:\\Users\\Andrea R\\AppData\\Roaming\\npm-cache
npm config set cache 'C:\\Users\\Andrea~1\\AppData\\Roaming\\npm-cache'
npm config set cache 'C:\\Users\\Andrea~1\\AppData\\Roaming\\npm-cache'
github 上有问题,所以真的不知道该告诉你什么,但尝试安装旧版本的 CRA 链接: github.com/facebook/create-react-app/issues/6512
I have tried it several times but was not successful .我已经尝试了几次,但没有成功。 The main reason behind this was my username in the system was "Kumar Sanket" and it was not able to read anything after space.
这背后的主要原因是我在系统中的用户名是“Kumar Sanket”,它在空格后无法读取任何内容。 when I changed my username i was able to run the commands.
当我更改用户名时,我能够运行命令。 Thanks all for support Kumar Sanket
感谢大家支持 Kumar Sanket
Install create-react-app using npm install -g create-react-app使用 npm install -g create-react-app 安装 create-react-app
then use create-react-app my-app然后使用 create-react-app my-app
no npm or npx before create-react app.在创建反应应用程序之前没有 npm 或 npx。
This EEXIST error happens due to path to node-cache directory contains a whitespace.由于节点缓存目录的路径包含空格,因此会发生此 EEXIST 错误。
Steps worked for me:步骤对我有用:
node-cache
where path does not have any whitespace.node-cache
的目录,其中路径没有任何空格。npm install --cache path/to/node-cache
npm install --cache path/to/node-cache
安装节点缓存内容npm config set cache path/to/node-cache
npm config set cache path/to/node-cache
设置新的节点缓存目录npx create-react-app my-app
npx create-react-app my-app
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.