gpt4 book ai didi

reactjs - sh : 1: webpack: not found

转载 作者:行者123 更新时间:2023-12-02 18:54:11 24 4
gpt4 key购买 nike

我正在开发 React+Django 应用当我调用 npm run dev

我收到一个错误

sh: 1: webpack: not found

npm ERR! Linux 4.4.0-197-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "dev"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! frontend@1.0.0 dev: `webpack --mode development ./src/index.js --output ./static/frontend/main.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the frontend@1.0.0 dev script 'webpack --mode development ./src/index.js --output ./static/frontend/main.js'.
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 frontend package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack --mode development ./src/index.js --output ./static/frontend/main.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs frontend
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls frontend
npm ERR! There is likely additional logging output above.

package.json

{
"name": "frontend",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"dev": "webpack --mode development ./src/index.js --output ./static/frontend/main.js",
"build": "webpack --mode production ./src/index.js --output ./static/frontend/main.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {},
"devDependencies": {
"react": "^17.0.1",
"react-dom": "^17.0.1"
},
"description": ""
}

发现在 ./node_modules/.bin/ 我只有 loose-envify -> ../loose-envify/cli.js*我读了这个问题 Webpack command not found ,但不明白如何解决我的错误。

最佳答案

您正在尝试使用 webpack 但它未在 devDependencies 下列出。

在您的终端中,运行 npm install --save-dev webpack 然后重试。

我可能不是 100% 正确地使用该命令,因为我通常使用 yarn 并且命令是 yarn add --dev webpack - 但我 100% 确定这是你的问题。

关于reactjs - sh : 1: webpack: not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66413196/

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