为什么NPM Start在React App中不起作用?

我试图将npm start运行到可以正常运行的React应用程序,但是由于某种原因现在无法正常工作。我收到的消息如下:

Error: Cannot find module 'C:\Users\albat\Desktop\personal_projects\alba_virtual_cv\index.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at internal/main/run_main_module.js:17:11 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! alba_virtual_cv@1.0.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the alba_virtual_cv@1.0.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\albat\AppData\Roaming\npm-cache\_logs\2020-05-11T09_08_43_976Z-debug.log

我的package.json如下:

{
  "name": "alba_virtual_cv",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "debug": "^4.1.1"
  },
  "devDependencies": {},
  "description": ""
}

请我需要帮助以再次运行该应用程序。

谢谢。

评论
  • 那只喵
    那只喵 回复

    在启动项目之前运行以下命令:

    npm -i

    这将安装缺少的软件包

  • 哼~
    哼~ 回复

    这仅表示在首次安装依赖项时出了点问题。

    我建议执行以下三个步骤:

    1. npm install -g npm@latest to update npm because it is sometimes buggy.
    2. rm -rf node_modules to remove the existing modules.
    3. npm install to re-install the project dependencies.

    这应该可以解决问题。