gpt4 book ai didi

json - 通过 npm run 运行时 Webpack 失败

转载 作者:太空宇宙 更新时间:2023-11-03 23:29:18 24 4
gpt4 key购买 nike

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

npm run webpack -p

它给出了以下错误。

npm ERR! Linux 4.4.0-43-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "webpack" "-i"
npm ERR! node v6.8.1
npm ERR! npm v3.10.8
npm ERR! file /home/phani/test/package.json
npm ERR! code EJSONPARSE

npm ERR! Failed to parse json
npm ERR! Trailing comma in object at 9:3
npm ERR! },
npm ERR! ^
npm ERR! File: /home/phani/test/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.parse

npm ERR! Please include the following file with any support request:
npm ERR! /home/phani/test/npm-debug.log

这是错误日志,

   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。错误仍然存​​在。

最佳答案

Npm 无法识别 webpack,因为它是依赖项之一,而不是 NPM 脚本。

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

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

然后使用npm run build运行它。

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

关于json - 通过 npm run 运行时 Webpack 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40102546/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com