npm start缺少脚本:开始

时间:2020-08-17 19:50:00

标签: javascript node.js reactjs

当我尝试输入“ npm start”时,这是我的命令提示符向我显示的内容:

┌──────────────────────────────────────────────────────────────────────────┐
│                         npm update check failed                          │
│                   Try running with sudo or get access                    │
│                   to the local update config store via                   │
│ sudo chown -R $USER:$(id -gn $USER) C:\Users\User's privacy\.config │
└──────────────────────────────────────────────────────────────────────────┘
npm ERR! missing script: start

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User's privacy\AppData\Roaming\npm-cache\_logs\2020-08-17T19_46_48_248Z-debug.log

有人能以某种方式帮助我吗?

这是我的package.json文件:

{ “ name”:“ react-app”, “ version”:“ 0.1.0”, “私人”:是的, “依赖关系”:{ “ react”:“ ^ 16.13.1”, “ react-dom”:“ ^ 16.13.1”, “反应脚本”:“ 3.4.3” } }

3 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,问题是当 npm 在我的笔记本电脑上加载完整的 React 项目时我中断了它,因为它需要超过 5 分钟而我没有意识到这一点。结果,

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  }

丢失了,还有很多其他东西。 如果项目已完全加载,您的 package.json 将如下所示:

{
  "name": "app0",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.9",
    "@testing-library/react": "^11.2.5",
    "@testing-library/user-event": "^12.7.1",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-scripts": "4.0.2",
    "web-vitals": "^1.1.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

答案 1 :(得分:0)

您应该在package.json

中添加类似的内容
  "scripts": {
    "start": "node index.js",
  },

答案 2 :(得分:0)

通常,查看错误将为您提供一些解决问题的详细信息。在这种情况下,您会看到错误:

“ npm ERR!缺少脚本:开始”

这意味着节点正在寻找启动脚本。这意味着您需要在 package.json 文件中添加脚本。

文件中的内容如下:

"scripts": { "start" : "bar ./test" } }