得到错误!缺少脚本:从<npm start>命令开始

时间:2019-08-22 18:08:25

标签: reactjs npm npm-scripts

当我运行npm start时,我得到了可怕的“ npm ERR!missing script:start”


已经尝试以此处显示的所有方式以及在整整一年的Google上更改package.json中的“开始”行。

还尝试安装从当前版本到12.x的几乎每个稳定节点/ npm稳定版本。只是为了确保删除了纱线。 Wnet回到当前版本。

运行从npm init到npm create-react-app [项目文件夹]的所有内容 有node_modules。

用于运行的脚本确实显示在package.json中。

删除项目目录,删除存储库,然后重新克隆新的存储库。


操作系统:Linux Mint 19.1 Cinnamon Linux Mint 19.1基于Ubuntu 18.04.1 相对于代码1.37.1-禁用所有扩展。

$ npm -v
6.9.0

$ whereis node
node: /usr/bin/node /usr/include/node /usr/share/man/man1/node.1.gz

$ which npm 
/usr/bin/npm

*******************************************
*package.json*:
{
  "main": "index.js",
  "name": "team-builder",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.9.0",
    "react-dom": "^16.9.0",
    "react-scripts": "3.1.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"
    ]
  }
}
  • 注意:去年,我已经尝试过在此处发布的启动脚本的所有变体。

debug.log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using npm@6.9.0
3 info using node@v10.16.3
4 verbose config Skipping project config: /home/mark/.npmrc. (matches 
 userconfig)
5 verbose stack Error: missing script: start
5 verbose stack     at run (/usr/lib/node_modules/npm/lib/run- 
 script.js:155:19)
5 verbose stack     at /usr/lib/node_modules/npm/lib/run- 
 script.js:63:5
5 verbose stack     at /usr/lib/node_modules/npm/node_modules/read- 
  package-json/read-json.js:115:5
5 verbose stack     at /usr/lib/node_modules/npm/node_modules/read- 
 package-json/read-json.js:418:5
5 verbose stack     at checkBinReferences_ 
  (/usr/lib/node_modules/npm/node_modules/read-package-json/read- 
 json.js:373:45)
5 verbose stack     at final 
  (/usr/lib/node_modules/npm/node_modules/read-package-json/read - 
 json.js:416:3)
5 verbose stack     at then 
  (/usr/lib/node_modules/npm/node_modules/read-package-json/read- 
  json.js:160:5)
5 verbose stack     at ReadFileContext.<anonymous> 
  (/usr/lib/node_modules/npm/node_modules/read-package-json/read- 
 json.js:3 32:20)
5 verbose stack     at ReadFileContext.callback 
 (/usr/lib/node_modules/npm/node_modules/graceful-fs/graceful- 
 fs.js:90:16)
5 verbose stack     at FSReqWrap.readFileAfterOpen [as oncomplete] 
 (fs.js:237:13)
6 verbose cwd /home/mark/OneDrive/Repositories/team-builder
7 verbose Linux 4.15.0-58-generic
8 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
9 verbose node v10.16.3
10 verbose npm  v6.9.0
11 error missing script: start
12 verbose exit [ 1, true ]

我几乎尝试了所有事情。希望大家能提供帮助。 npm start不会运行,所以我基本上是在盲目编写代码-监视器没有任何内容,没有Chrome React devTools。

1 个答案:

答案 0 :(得分:2)

您的package.json中的“脚本”部分看起来不正确,也许您可​​以将启动脚本更改为以下内容:

"start": "react-scripts start",

作为完整参考,假设您尝试使用react cli自举的create-react-app,则脚本部分应与此类似:

package.json

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

希望有帮助!