NPM失败:无法解析JSON

  • 本文关键字:JSON 失败 NPM 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缓存清洁",但它没有起作用...
谁能帮我?多谢!

您在test脚本内什么都不做!(只是试图重新安装摩卡!(。

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

您应该编辑 test 脚本"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:UsersProjecttestpackage.json
npm ERR! Failed to parse package.json data.

打开您的软件包。JSON并输入:

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

最新更新