【问题标题】:Unable to start project after create-react-app: Error: Cannot find module 'C:\Users\pcname\Documents\react-scripts\bin\react-scripts.js'create-react-app 后无法启动项目:错误:找不到模块 'C:\Users\pcname\Documents\react-scripts\bin\react-scripts.js'
【发布时间】:2020-07-21 11:51:33
【问题描述】:

我使用 npx create-react-app 创建了一个小型反应项目来处理一些反应教程,但我无法启动反应应用程序。这是我在尝试运行项目时遇到的错误:

> test-app@0.1.0 start C:\Users\pcname\Documents\React R&D\Pluralsight\test-app
> react-scripts start

'D\Pluralsight\test-app\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:983
  throw err;
  ^

Error: Cannot find module 'C:\Users\pcname\Documents\react-scripts\bin\react-scripts.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
    at Function.Module._load (internal/modules/cjs/loader.js:862: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! test-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test-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\pcnmame\AppData\Roaming\npm-cache\_logs\2020-04-08T22_43_14_881Z-debug.log

我已经卸载了节点,重新安装了它。全局而不是全局安装 react-scripts。我已将 package.json 中的启动脚本替换为:

"start": "node node_modules/react-scripts/scripts/start.js"

这行得通。我还在 app 文件夹中运行了 react-scripts start ,并且再次运行!但是当我在应用程序文件夹中执行 npm start 时,我无法让它工作

奖励:任何不使用 ASP NET Core 在 Visual Studio(不是 vs 代码)中设置 React 的教程将不胜感激。我目前无法使用 VS 设置调试器。

【问题讨论】:

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


    【解决方案1】:

    重新运行npm i 解决了我的问题。 我有同样的问题,原来“重新安装” npm 包摆脱了烦人的

    错误:找不到模块“C:\Users\pcname\Documents\react-scripts\bin\react-scripts.js” . . . { 代码:'MODULE_NOT_FOUND', 要求堆栈:[] }

    错误信息。

    【讨论】:

      【解决方案2】:

      使用create-react-app 后可能会发生此错误,以防您的路径中有一些无效字符。

      从路径中删除 &

      从此改变:

      C:\Users\pcname\Documents\React R&D\Pluralsight\test-app
      

      到这里:

      C:\Users\pcname\Documents\React RD\Pluralsight\test-app
      

      它现在应该可以工作了!

      【讨论】:

        猜你喜欢
        • 2020-07-09
        • 2021-04-02
        • 2019-12-30
        • 2019-04-26
        • 1970-01-01
        • 1970-01-01
        • 2019-11-19
        • 1970-01-01
        • 2019-08-17
        相关资源
        最近更新 更多