我想在react中创建一个应用程序。我已经安装了最新的Node js 当我运行命令时出现错误
PS C:\ Users \ Kumar Sanket \ Desktop \ React&Redux> npx create-react-app myapp 错误:EEXIST:文件已经存在,mkdir'C:\ Users \ Kumar' TypeError:无法读取未定义的属性“ get” 在errorHandler(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 在Array.forEach() 在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) 在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:无法读取未定义的属性“ get” 在process.errorHandler(C:\ Program Files \ nodejs \ node_modules \ npm \ lib \ utils \ error-handler.js:205:18) 在process.emit(events.js:189:13) 在process._fatalException(内部/引导/node.js:496:27) 安装create-react-app @ latest失败,原因是c
答案 0 :(得分:4)
问题是用户名中的空格。我使用Windows 10,并通过更改npm缓存文件夹的路径来解决此问题:
npm config get cache
来检查配置文件中属性缓存的值C:\Users\Andrea R\AppData\Roaming\npm-cache
npm config set cache 'C:\Users\Andrea~1\AppData\Roaming\npm-cache'
答案 1 :(得分:0)
github上有问题,所以,真的不知道该告诉您什么,但是请尝试安装旧版本的CRA 链接:github.com/facebook/create-react-app/issues/6512
答案 2 :(得分:0)
我尝试了几次,但没有成功。这背后的主要原因是我在系统中的用户名是“ Kumar Sanket”,并且在空格后无法读取任何内容。 当我更改用户名时,我能够运行命令。 谢谢大家的支持 库玛·桑凯特
答案 3 :(得分:0)
今天,我在 npx create-react-app my-app (mkdir失败)中遇到了类似的问题。
造成错误的原因
我的用户名文件夹(例如:Abc Xyz)中有空格,因此“ npx” 无法正确引用它(它仅读取Abc,而不读取Xyz)。
我正在使用VS Code for React,它没有创建新目录的权限
我如何修复
使用管理员权限打开了VS代码。(已修复权限问题)
我尝试了以下操作,而不是使用“ npx” :
-> npm install -g create-react-app
-> create-react-app my-app
成功执行。
希望这会有所帮助。
答案 4 :(得分:0)
使用安装 create-react-app npm install -g create-react-app
然后使用 create-react-app my-app
在 create-react 应用程序之前没有 npm 或 npx。
答案 5 :(得分:0)
此 EEXIST 错误是由于节点缓存目录的路径包含空格而发生的。
对我有用的步骤:
node-cache
的目录,其中路径没有任何空格。npm install --cache path/to/node-cache
npm config set cache path/to/node-cache
npx create-react-app my-app