[英]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.