create-react-app 在我的系统中不起作用

问题描述 投票:0回答:2

当我尝试创建我的反应项目时,它显示错误日志

C:\Users\Ezhil & rishii>npx create-react-app firstapp
'rishii\AppData\Roaming\npm\' is not recognized as an internal or external command,
operable program or batch file.
node:internal/modules/cjs/loader:1147
  throw err;
  ^

Error: Cannot find module 'C:\Users\Ezhil \node_modules\create-react-app\index.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.10.0

这是我的cmd中显示的错误日志

reactjs node.js npm create-react-app
2个回答
0
投票

检查您的 NPM 是否正常工作。 使用

npm -v
尝试一下,它应该显示已安装的 npm 版本。

如果这不起作用,请检查 NPM 是否是您的 PATH 变量的一部分。 如果没有,请将其添加到您的路径中:

C:\Users\Ezhil\AppData\Roaming\npm


0
投票

npm 路径的问题可能是由于用户名中的空格(“Ezhil & rishii”)造成的。要解决此问题,请转到名称中没有空格的文件夹,然后再次运行该命令。 这是例子:

 cd C:\Users\Ezhil_rishii // use the directory name like this
npx create-react-app firstapp
© www.soinside.com 2019 - 2024. All rights reserved.