【问题标题】:npx create-react-app not working, file already existsnpx create-react-app 不工作,文件已经存在
【发布时间】:2020-02-04 20:51:21
【问题描述】:

我已按照建议在全局范围内卸载了 create-react-app。然后我跑了npx create-react-app test,出现如下错误

Error: EEXIST: file already exists, mkdir 'C:\Users\User'
TypeError: Cannot read property 'loaded' of undefined
    at exit (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:97: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:78: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:81:7
    at Array.forEach (<anonymous>)
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:80: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:171:20)
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:97
  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:97:27)
    at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:216:3)
    at process.emit (events.js:223:5)
    at process._fatalException (internal/process/execution.js:150:25)
Install for [ 'create-react-app@latest' ] failed with code 7

我在网上搜索并尝试了以下npm cache clean --force。没用。

我确保全局卸载 create-react-app。然后跑which create-react-app

它给了我一个错误

'which' is not recognized as an internal or external command,
operable program or batch file.

所以现在我必须做npm install -g create-react-app,不再推荐?

如果您之前通过 npm install -g create-react-app 全局安装了 create-react-app,我们建议您使用 npm uninstall -g create-react-app 卸载该软件包,以确保 npx 始终使用最新的版本。

我该如何解决这个问题?

【问题讨论】:

    标签: npm create-react-app npm-install npx


    【解决方案1】:

    我收到了和你一样的错误。

    我尝试了以下方法:

    1. npm cache clean --force,这对我不起作用
    2. 从系统中删除节点,重新安装,然后调用npx create-react-app &lt;appname&gt;;再次,这对我不起作用
    3. 使用npm install -g create-react-app全局安装create-react-app,然后使用create-react-app &lt;appname&gt;创建React应用程序的命令

    最后,在第三步之后,它对我来说成功了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 2023-02-05
      • 2021-03-05
      • 2019-07-16
      • 2021-06-17
      • 2022-01-17
      • 1970-01-01
      相关资源
      最近更新 更多