【问题标题】:during npm install getting Failed to parse package.json data在 npm install 期间无法解析 package.json 数据
【发布时间】:2017-10-12 04:37:46
【问题描述】:

在 Windows 10 上安装 npm 期间,我收到此错误 我正在使用节点 v6.10.3 和 npm v3.10.10

请帮助纠正这个问题。

我得到的错误

npm ERR! npm  v3.10.10
npm ERR! file C:\angular2-helloworld\package.json
npm ERR! code EJSONPARSE

npm ERR! Failed to parse json
npm ERR! Unexpected token '\r' at 5:71
npm ERR!     "start": "tsc && concurrently \"npm run tsc:w\" \"npm run 
lite\"\
npm ERR!                                                                      
^
npm ERR! File: C:\angular2-helloworld\package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. 
JSON.parsenpm ERR! node v6.10.3

package.json 文件内容:

{  
   "name":"angular2-helloworld",
   "version":"1.0.0",
   "scripts":{  
      "start":"tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
      "tsc":"tsc",
      "tsc:w":"tsc -w",
      "lite":"lite-server",
      "typings":"typings",
      "postinstall":"typings install"
   },
   "license":"ISC",
   "dependencies":{  
      "angular2":"2.0.0-beta.14",
      "systemjs":"0.19.25",
      "es6-shim":"^0.35.0",
      "reflect-metadata":"0.1.2",
      "rxjs":"5.0.0-beta.2",
      "zone.js":"0.6.6"
   },
   "devDependencies":{  
      "concurrently":"^2.0.0",
      "lite-server":"^2.2.0",
      "typescript":"^1.8.9",
      "typings":"^0.7.12"
   }
}

【问题讨论】:

  • tsc 任务是做什么的?另外,为什么在您的启动脚本中您启动 tsc 时没有 npm run,但您启动 tsc:w 为 npm run tsc:w?
  • \r 表示回车。 NPM 抱怨第 5 行末尾的回车。您使用什么文本编辑器来更改 package.json?
  • 我正在使用notepad ++对其进行更改

标签: json node.js angular npm


【解决方案1】:

你可能有一个隐形字符\r在行:

"start":"tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",

该字符破坏了package.json 文件的 json 解析。 尝试手动重写该部分文本,或使用正则表达式搜索在您的文本编辑器中将其删除。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-30
    • 2021-04-29
    • 2021-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多