gpt4 book ai didi

ubuntu - 当我尝试运行 npm run build 命令时出现一堆错误

转载 作者:行者123 更新时间:2023-12-04 19:10:11 25 4
gpt4 key购买 nike

我正在尝试按照 this 设置 Webpack教程,但是当我尝试运行命令时出现错误

npm run build

节点 : v8.10.0

Ubuntu : 18.04

错误
sh: 1: Webpack: not found
npm ERR! Linux 4.15.0-54-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "build"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! webpacks@1.0.0 build: `Webpack --mode development`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the webpacks@1.0.0 build script 'Webpack --mode development'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the webpacks package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! Webpack --mode development
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs webpacks
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls webpacks
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /var/www/html/webpacks/npm-debug.log

日志
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build' ]
2 info using npm@3.5.2
3 info using node@v8.10.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle webpacks@1.0.0~prebuild: webpacks@1.0.0
6 silly lifecycle webpacks@1.0.0~prebuild: no script for prebuild, continuing
7 info lifecycle webpacks@1.0.0~build: webpacks@1.0.0
8 verbose lifecycle webpacks@1.0.0~build: unsafe-perm in lifecycle true
9 verbose lifecycle webpacks@1.0.0~build: PATH: /usr/share/npm/bin/node-gyp-bin:/var/www/html/webpacks/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
10 verbose lifecycle webpacks@1.0.0~build: CWD: /var/www/html/webpacks
11 silly lifecycle webpacks@1.0.0~build: Args: [ '-c', 'Webpack --mode development' ]
12 info lifecycle webpacks@1.0.0~build: Failed to exec build script
13 verbose stack Error: webpacks@1.0.0 build: `Webpack --mode development`
13 verbose stack spawn ENOENT
13 verbose stack at ChildProcess.<anonymous> (/usr/share/npm/lib/utils/spawn.js:17:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid webpacks@1.0.0
15 verbose cwd /var/www/html/webpacks
16 error Linux 4.15.0-54-generic
17 error argv "/usr/bin/node" "/usr/bin/npm" "run" "build"
18 error node v8.10.0
19 error npm v3.5.2
20 error file sh
21 error code ELIFECYCLE
22 error errno ENOENT
23 error syscall spawn
24 error webpacks@1.0.0 build: `Webpack --mode development`
24 error spawn ENOENT
25 error Failed at the webpacks@1.0.0 build script 'Webpack --mode development'.
25 error Make sure you have the latest version of node.js and npm installed.
25 error If you do, this is most likely a problem with the webpacks package,
25 error not with npm itself.
25 error Tell the author that this fails on your system:
25 error Webpack --mode development
25 error You can get information on how to open an issue for this project with:
25 error npm bugs webpacks
25 error Or if that isn't available, you can get their info via:
25 error npm owner ls webpacks
25 error There is likely additional logging output above.
26 verbose exit [ 1, true ]

包.json
{
"name": "webpacks",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "Webpack --mode development"
},
"author": "",
"license": "ISC",
"devDependencies": {
"webpack": "^4.39.3"
}
}

我尝试使用 npm i webpack -g 全局安装 webpack根据建议 here但这没有帮助

我已成功捆绑保存在 dist 文件夹中的 main.js 文件,这发生在我运行 webpack-cli 之后命令,如果我对捆绑的文件进行更改,如果我运行 webpack-cli,它们将首先捆绑再次

最佳答案

您必须将 package.json 中的 webpack 命令更改为小写而不是驼峰式,您正在编写 Webpack在构建脚本中,

    "build": "webpack --mode development"

关于ubuntu - 当我尝试运行 npm run build 命令时出现一堆错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57831971/

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