【问题标题】:ReactJs error : npm start not working , I also tied " npm cache clean --force ". I am stuck in the middle of my projectReactJs 错误:npm start 不工作,我还绑定了“npm cache clean --force”。我被困在我的项目中间
【发布时间】:2020-05-20 20:49:12
【问题描述】:

这是错误:

my-app@0.1.0 start /home/gaurav/Desktop/Django + React/Saurav Hardware/saurav_hardware/my-app 反应脚本开始

                sh: 1: react-scripts: not found
                npm ERR! code ELIFECYCLE
                npm ERR! syscall spawn
                npm ERR! file sh
                npm ERR! errno ENOENT
                npm ERR! my-app@0.1.0 start: `react-scripts start`
                npm ERR! spawn ENOENT
                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 WARN Local package.json exists, but node_modules missing, did you mean to install?

                npm ERR! A complete log of this run can be found in:
                npm ERR!     /home/gaurav/.npm/_logs/2020-05-20T20_38_00_671Z-`enter code here`debug.log



            [// This is my package.json]
            {
              "name": "my-app",
              "version": "0.1.0",
              "private": true,
              "dependencies": {
                "@testing-library/jest-dom": "^4.2.4",
                "@testing-library/react": "^9.5.0",
                "@testing-library/user-event": "^7.2.1",
                "react": "^16.13.1",
                "react-dom": "^16.13.1",
                "react-icons": "^3.10.0",
                "react-router-dom": "^5.2.0",
                "react-scripts": "3.4.1"
              },
              "scripts": {
                "start": "react-scripts start",
                "build": "react-scripts build",
                "test": "react-scripts test",
                "eject": "react-scripts eject"
              },
              "eslintConfig": {
                "extends": "react-app"
              },
              "browserslist": {
                "production": [
                  ">0.2%",
                  "not dead",
                  "not op_mini all"
                ],
                "development": [
                  "last 1 chrome version",
                  "last 1 firefox version",
                  "last 1 safari version"
                ]
              }
            }

每次我尝试启动 npm 时都会发生这种情况。它昨天工作正常,但完全停止了。我该怎么办?这个 package.json 文件中缺少什么?我也无法安装节点模块.......!

【问题讨论】:

  • 你能把你的package.json加进来
  • 只要删除 package-lock.json 我希望它消失
  • 删除你的node_modules目录,运行命令npm install,然后再试一次
  • 本地 package.json 存在,但缺少 node_modules,你的意思是要安装吗?
  • 这能回答你的问题吗? How do I debug "Error: spawn ENOENT" on node.js?

标签: reactjs npm


【解决方案1】:

您尚未安装所有模块。运行npm install 以安装package.json 中指定的模块,然后npm start 应该可以工作。从错误信息中注意,react-scripts is not found,这是你没有安装包的线索

【讨论】:

  • npm install npm WARN 已弃用 urix@0.1.0:请参阅 github.com/lydell/urix#deprecated npm WARN 已弃用 resolve-url@0.2.1:github.com/lydell/resolve-url#deprecated npm ERR!在 '...,"jest-resolve":"24.9' npm ERR 附近解析时 JSON 输入意外结束!此运行的完整日志可在以下位置找到:npm ERR!/home/gaurav/.npm/_logs/2020 -05-20T21_10_08_916Z-debug.log 这是我的错误。
  • @gauravraj 你能不能尝试运行这两个命令npm cache clean --force && npm update 然后再试一次
  • @gauravraj 请参阅此answer,了解您收到Unexpected end of JSON input 错误的原因
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-12-17
  • 2018-01-27
  • 1970-01-01
  • 1970-01-01
  • 2023-02-09
  • 2021-10-17
  • 1970-01-01
相关资源
最近更新 更多