[英]Why can't I successfully run “npm start” command on mac?
我正在尝试安装 npm 并且我不断收到错误消息。 最初的问题是我需要一个 package-lock.json 文件和 package.json 文件,这可以通过在终端中输入“npm init”来解决。
然后当试图运行“npm start”时,它说我错过了启动脚本。 于是我打开package.json文件添加如下图:
{
"name": "arvinder",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
现在我收到以下错误:
Arvinders-MacBook-Air:~ Arvinder$ npm start
npm ERR! file /Users/Arvinder/package.json
npm ERR! code EJSONPARSE
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected string in JSON at position 137 while parsing '{
npm ERR! JSON.parse "name": "arvinder",
npm ERR! JSON.parse "version": "1.'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Arvinder/.npm/_logs/2020-07-24T16_26_18_155Z-debug.log
我不确定 json 文件中的错误在哪里,或者为什么它无法解析它,所以如果有人可以帮助指出一个非常感谢的解决方案。
好像您在第 7 行中缺少逗号,在"start": "node index.js"
之后。 这是正确的:
{
"name": "arvinder",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
我建议您为 IDE 安装一个扩展,它可以捕获 JSON 文件上的语法错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.