首页 > 解决方案 > ReactJs 错误:npm start 不工作,我还绑定了“npm cache clean --force”。我被困在我的项目中间

问题描述

这是错误:

my-app@0.1.0 start /home/gaurav/Desktop/Django + React/Saurav Hardware/saurav_hardware/my-app react-scripts start

                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 文件中缺少什么?我也无法安装节点模块......!

标签: reactjsnpm

解决方案


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


推荐阅读