簡體   English   中英

npm失敗:無法解析json

[英]npm failed : Failed to parse json

我想使用npm在Ubuntu 16.04 LTS中運行測試腳本。 但是,它顯示以下錯誤:

npm ERR! Linux 4.4.0-116-generic        
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "test"
npm ERR! node v4.2.6        
npm ERR! npm  v3.5.2        
npm ERR! file /home/parth/Documents/Ethereum/Project/inbox/package.json        
npm ERR! code EJSONPARSE         
npm ERR! Failed to parse json
npm ERR! No data, empty input at 1:1
npm ERR! ^        
npm ERR! File: /home/parth/Documents/Ethereum/Project/inbox/package.json        
npm ERR! Failed to parse package.json data.        
npm ERR! package.json must be actual JSON, not just JavaScript.         
npm ERR! This is not a bug in npm.         
npm ERR! Tell the package author to fix their package.json file. JSON.parse

我的劇本:

{
"name": "inbox",
"version":"1.0.0",
"description":"",
"main":"index.js",
"scripts":{
"test":"mocha"
},
"author":"",
"license":"ISC",
"devDependencies":{
"ganache-cli":"^6.0.3",
"mocha":"^4.0.1",
"sloc":"^0.4.19",
"web3":"^1.0.0-beta.26"
}
}

我也曾嘗試使用“ npm cache clean”,但是沒有用...
誰能幫我? 非常感謝!

您在test腳本中什么也不做! (只是嘗試重新安裝摩卡!)。

"scripts":{
"test":"mocha"
}

您應該編輯測試腳本"test":" Action_to_lunch"

如果您嘗試運行測試並收到以下錯誤:

 Failed to parse json
npm ERR! Unexpected token : in JSON at position 9 while parsing near '"scripts": {
npm ERR!     "test": "mo...'
npm ERR! File: C:\Users\Project\test\package.json
npm ERR! Failed to parse package.json data.

打開您的package.json並輸入:

{
    "scripts": {
        "test": "mocha"
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM