运行npm run时Webpack失败

时间:2016-10-18 07:51:38

标签: json node.js ubuntu reactjs webpack

我正在尝试设置React。当我尝试运行时

A.includes(:bs).where('as.disabled = false OR bs.id = 1')

它会出现以下错误。

npm run webpack -p

这是错误日志,

   0 info it worked if it ends with ok
    1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'run', 'webpack', '-i' ]
    2 info using npm@3.10.8
    3 info using node@v6.8.1
    4 verbose stack Error: Failed to parse json
    4 verbose stack Trailing comma in object at 9:3
    4 verbose stack   },
    4 verbose stack   ^
    4 verbose stack     at parseError (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:390:11)
    4 verbose stack     at parseJson (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:79:23)
    4 verbose stack     at /usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:48:5
    4 verbose stack     at /usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16
    4 verbose stack     at tryToString (fs.js:455:3)
    4 verbose stack     at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:442:12)
    5 verbose cwd /home/phani/test
    6 error Linux 4.4.0-43-generic
    7 error argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "webpack" "-i"
    8 error node v6.8.1
    9 error npm  v3.10.8
    10 error file /home/phani/test/package.json
    11 error code EJSONPARSE
    12 error Failed to parse json
    12 error Trailing comma in object at 9:3
    12 error   },
    12 error   ^
    13 error File: /home/phani/test/package.json
    14 error Failed to parse package.json data.
    14 error package.json must be actual JSON, not just JavaScript.
    14 error
    14 error This is not a bug in npm.
    14 error Tell the package author to fix their package.json file. JSON.parse
    15 verbose exit [ 1, true ]

我尝试在全球范围内安装webpack。仍然存在错误。

1 个答案:

答案 0 :(得分:2)

Npm并不认识webpack因为它是其中一个依赖项,而不是NPM脚本。

如果您在本地安装webpack(首选方法) - 在package.json添加脚本:

"scripts": {
   "build": "webpack -p"
}

然后使用npm run build运行它。

如果您想使用全局安装的webpack,请使用webpack -p(不使用npm run)运行它。