【问题标题】:Npm start not working after running create-react-app ONLY in Documents directory仅在 Documents 目录中运行 create-react-app 后,npm start 无法正常工作
【发布时间】:2020-07-11 08:25:39
【问题描述】:

我整天都在与这个问题作斗争,但仍然无法弄清楚我错过了什么。我一直在计算机上的 Documents 目录下创建我的项目,但是在使用 create-react-app 后尝试启动项目时,我开始收到以下错误。

my-app@0.1.0 start C:\Users\{user}\Documents\B&R Fun\nginx_test_deploy\my-app

react-scripts start

'R' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:985
  throw err;
  ^

Error: Cannot find module 'C:\Users\{user}\Documents\react-scripts\bin\react-scripts.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
    at Function.Module._load (internal/modules/cjs/loader.js:864:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\{user}\AppData\Roaming\npm-cache\_logs\2020-03-30T21_02_14_553Z-debug.log

有趣的是,在我的桌面上运行完全相同的命令会创建一个没有错误的应用程序。我是否缺少某些可能会影响在“文档”文件夹下创建的应用的配置?

【问题讨论】:

    标签: node.js reactjs npm create-react-app npm-start


    【解决方案1】:

    尝试重命名 B&R Fun 文件夹以避免出现 & 符号。似乎& 打破了一切。见this issue

    【讨论】:

      【解决方案2】:

      您应该尝试清除并重新安装 node_modules。您可以通过运行以下命令来执行此操作。

      rm -rf node_modules package-lock.json && npm install && npm start
      

      另外,升级到nodenpm 的更高版本。

      【讨论】:

        猜你喜欢
        • 2019-03-18
        • 2020-09-23
        • 2019-07-03
        • 1970-01-01
        • 1970-01-01
        • 2023-02-05
        • 2021-01-03
        • 2020-11-17
        • 1970-01-01
        相关资源
        最近更新 更多