npm失败:无法解析json

时间:2018-02-24 17:04:17

标签: json npm

我想使用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”,但它没有用...... 谁能帮我?非常感谢!

2 个答案:

答案 0 :(得分:0)

您在test脚本中没有任何操作! (刚尝试重新安装摩卡!)。

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

您应该修改测试脚本"test":" Action_to_lunch"

答案 1 :(得分:0)

如果您尝试运行测试,则会收到以下错误:

 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"
    }
}