node.js - 如何修复这个 package.json 文件中的 NPM EJSONParse?

标签 node.js json npm npm-scripts

在我准备好自动脚本并安装几个包来自动化我的任务后,我收到以下错误:

npm ERR! file C:\Users\windw\Desktop\bootstrap4\package.json
npm ERR! code EJSONPARSE
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected string in JSON at position 455 while parsing '{
npm ERR! JSON.parse   "name": "confusion",
npm ERR! JSON.parse   "version": '
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
下面是我的 package.json文件
{
  "name": "confusion",
  "version": "1.0.0",
  "description": "This is a website for Ristorante Con Fusion",
  "main": "index.html",
  "scripts": {
    "start": "npm run watch:all",
    "test": "echo \"Error: no test specified\" && exit 1",
    "lite": "lite-server",
    "scss": "node-sass -o css/ css/",
    "watch:scss": "onchange \"css/*.scss\" -- npm run scss",
    "watch:all": "parallelshell \"npm run watch:scss\" \"npm run lite\""
    "clean": "rimraf dist",
    "copyfonts": "copyfiles -f node_modules/font-awesome/fonts/* dist/fonts",
    "imagemin": "imagemin img/* --out-dir='dist/img'",
    "usemin": "usemin contactus.html -d dist --htmlmin -o dist/contactus.html && usemin aboutus.html -d dist --htmlmin -o dist/aboutus.html && usemin index.html -d dist --htmlmin -o dist/index.html",
    "build": "npm run clean && npm run imagemin && npm run copyfonts && npm run usemin"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "cssmin": "^0.4.3",
    "htmlmin": "0.0.7",
    "lite-server": "^2.3.0",
    "node-sass": "^4.7.2",
    "onchange": "^6.1.0",
    "parallelshell": "^3.0.2",
    "rimraf": "^2.6.2",
    "uglifyjs": "^2.4.11",
    "usemin-cli": "^0.5.1"
  },
  "dependencies": {
    "bootstrap": "^4.3.1",
    "bootstrap-social": "5.1.1",
    "font-awesome": "4.7.0",
    "jquery": "^3.4.1",
    "popper.js": "1.12.9"
  }
}
如何修复 NPM EJSONParse 错误?

最佳答案

您在 package.json 的第 12 行末尾缺少逗号文件。

目前它看起来像这样:

"watch:all": "parallelshell \"npm run watch:scss\" \"npm run lite\""

它应该是这样的:
"watch:all": "parallelshell \"npm run watch:scss\" \"npm run lite\"",

注意行尾的逗号。

关于node.js - 如何修复这个 package.json 文件中的 NPM EJSONParse?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59055126/

相关文章:

node.js - 更改 Windows 中 node.js 模块的默认全局安装目录?

node.js - 在 ubuntu VPS 16.04 上安装 Sails js?

javascript - 即使可用堆内存远大于已用内存,也会出现堆内存不足的错误

javascript - 如何比较数组的元素并根据条件合并?

javascript - 使用 string.prototype 每 8 个逗号后创建一个新行

javascript - 将 Facebook 图形 API JSON 解析为 html

javascript - Angular.copy 更改引用

Python 访问 JSON 对象中的数据

node.js - 解压大小如何影响 npm 包的最小大小?

javascript - 向 Node 注册 Glass Timeline 通知