npx create react-app 命令不起作用 [英] npx create react-app command doesn't work
问题描述
当我在终端中运行 create react-app 时,它显示一些错误.
When I run create react-app in terminal it display some errors.
npx 创建 react-app 示例
npx create react-app sample
Error: EPERM: operation not permitted, mkdir 'C:\Users\Yasiru'
TypeError: Cannot read property 'loaded' of undefined
at exit (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:98:27)
at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:216:3)
at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:77:20
at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:225:22)
at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:263:24
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:83:7
at Array.forEach (<anonymous>)
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)
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:98
var doExit = npm.config.loaded ? npm.config.get('_exit') : true
^
TypeError: Cannot read property 'loaded' of undefined
at exit (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:98:27)
at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:216:3)
at process.emit (events.js:196:13)
at process._fatalException (internal/process/execution.js:142:25)
Install for [ 'create@latest' ] failed with code 7
推荐答案
全局安装 create-react-app 时,不需要使用 npm/npx/yarn 运行命令.它是它自己的二进制文件,因此您只需键入create-react-app 目录",其中目录"是您要在其中创建 React 应用程序的目录.
When you install create-react-app globally, you do not need to run the command with npm/npx/yarn. It is its own binary, so all you should have to type is "create-react-app directory" where 'directory' is the directory you want to create the react app within.
另外,看起来您正在运行的命令是create react-app"而不是create-react-app",请确保不要错过第一个破折号,否则您将不会运行正确的命令.
Also, it looks like the command you're running is "create react-app" rather than "create-react-app", make sure you do not miss the first dash or you will not be running the correct command.
这篇关于npx create react-app 命令不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!