【发布时间】:2020-07-24 16:30:47
【问题描述】:
我正在尝试安装 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 文件中的错误在哪里,或者为什么它无法解析它,所以如果有人能帮助指出一个解决方案,将不胜感激。
【问题讨论】: