命令 "webpack" 未找到
Command "webpack" not found
我已经为我的 Rails 6.1 项目安装了 webpack
yarn add webpack
yarn add -D webpack-cli
yarn add @rails/webpacker@6.0.0-beta.6
bin/rails webpacker:install
直到最近一切都运行良好,但现在我收到错误
error Command "webpack" not found.
每当我执行以下任一操作时:
./bin/webpack
./bin/webpack-dev-server
yarn run webpack
我假设它是 yarn 运行 webpack,它被 webpack bin 命令运行“隐藏”,因为我对所有 3 个命令得到完全相同的输出:
yarn run v1.22.5
error Command "webpack" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
运行
bundle info webpacker
yarn list --pattern @rails/webpacker
都显示我安装了 beta.6 版本的 webpacker
我有package.json
# package.json
{
"name": "ancestors",
"private": true,
"dependencies": {
"@babel/core": "^7.12.10",
"@babel/parser": "^7.13.13",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-proposal-object-rest-spread": "^7.13.8",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-destructuring": "^7.13.0",
"@babel/plugin-transform-regenerator": "^7.12.13",
"@babel/plugin-transform-runtime": "^7.13.10",
"@babel/preset-env": "^7.13.10",
"@rails/actioncable": "^6.0.0",
"@rails/activestorage": "^6.0.0",
"@rails/ujs": "^6.0.0",
"@rails/webpacker": "^6.0.0-beta.6",
"babel-core": "^6.26.3",
"babel-loader": "^8.2.2",
"babel-plugins": "^1.0.0",
"coffee-loader": "^2.0.0",
"coffeescript": "^2.5.1",
"css-loader": "^5.1.3",
"css-minimizer-webpack-plugin": "^1.3.0",
"jquery": "^3.5.1",
"jquery-blockui": "^2.7.0",
"jquery-ui-dist": "^1.12.1",
"mini-css-extract-plugin": "^1.3.9",
"sass": "^1.32.8",
"sass-loader": "^11.0.1",
"style-loader": "^2.0.0",
"turbolinks": "^5.2.0",
"webpack": "^5.11.0"
},
"version": "0.1.0",
"devDependencies": {
"@webpack-cli/serve": "^1.3.0",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.11.2"
},
"engines": {
"yarn": "1.22.5"
},
"scripts": {
"heroku-prebuild": "echo This runs before Heroku installs dependencies.",
"heroku-postbuild": "echo This runs after Heroku installs dependencies, but before Heroku prunes and caches dependencies",
"heroku-cleanup": "echo This runs after Heroku prunes and caches dependencies."
}
}
和webpacker.yml
# webpacker.yml
# Note: You must restart bin/webpack-dev-server for changes to take effect
default: &default
source_path: app/packs
source_entry_path: entrypoints
public_root_path: public
public_output_path: packs
cache_path: tmp/cache/webpacker
webpack_compile_output: true
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
additional_paths: []
# Reload manifest.json on all requests so we reload latest compiled packs
cache_manifest: false
development:
<<: *default
compile: true
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
https: false
host: localhost
port: 3035
public: localhost:3035
# Inject browserside javascript that required by both HMR and Live(full) reload
inject_client: true
# Hot Module Replacement updates modules while the application is running without a full reload
hmr: false
# Inline should be set to true if using HMR; it inserts a script to take care of live reloading
inline: true
# Should we show a full-screen overlay in the browser when there are compiler errors or warnings?
overlay: true
# Should we use gzip compression?
compress: true
# Note that apps that do not check the host are vulnerable to DNS rebinding attacks
disable_host_check: true
# This option lets the browser open with your local IP
use_local_ip: false
# When enabled, nothing except the initial startup information will be written to the console.
# This also means that errors or warnings from webpack are not visible.
quiet: false
pretty: false
headers:
'Access-Control-Allow-Origin': '*'
watch_options:
ignored: '**/node_modules/**'
test:
<<: *default
compile: true
# Compile test packs to a separate directory
public_output_path: packs-test
production:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile: false
# Cache manifest.json for performance
cache_manifest: true
我终其一生都无法弄清楚现在缺少哪些安装或配置步骤,尤其是当它正在运行时,我不确定发生了什么破坏它?
欢迎提出任何建议。
让我大吃一惊的是,在 https://makandracards.com/makandra/432947-how-to-fix-webpack-dev-server-not-found 上提出建议后
运行 yarn install --check-files 修复这个错误,
我使用 vag运行t 从以管理员身份执行的命令提示符(在 Windows 下)、运行 命令以及我遇到的所有问题重新启动了 VirtualBox VM webpack 和 webpack-dev-server 已解决。
我希望这对某人有所帮助。
我已经为我的 Rails 6.1 项目安装了 webpack
yarn add webpack
yarn add -D webpack-cli
yarn add @rails/webpacker@6.0.0-beta.6
bin/rails webpacker:install
直到最近一切都运行良好,但现在我收到错误
error Command "webpack" not found.
每当我执行以下任一操作时:
./bin/webpack
./bin/webpack-dev-server
yarn run webpack
我假设它是 yarn 运行 webpack,它被 webpack bin 命令运行“隐藏”,因为我对所有 3 个命令得到完全相同的输出:
yarn run v1.22.5
error Command "webpack" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
运行
bundle info webpacker
yarn list --pattern @rails/webpacker
都显示我安装了 beta.6 版本的 webpacker
我有package.json
# package.json
{
"name": "ancestors",
"private": true,
"dependencies": {
"@babel/core": "^7.12.10",
"@babel/parser": "^7.13.13",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-proposal-object-rest-spread": "^7.13.8",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-destructuring": "^7.13.0",
"@babel/plugin-transform-regenerator": "^7.12.13",
"@babel/plugin-transform-runtime": "^7.13.10",
"@babel/preset-env": "^7.13.10",
"@rails/actioncable": "^6.0.0",
"@rails/activestorage": "^6.0.0",
"@rails/ujs": "^6.0.0",
"@rails/webpacker": "^6.0.0-beta.6",
"babel-core": "^6.26.3",
"babel-loader": "^8.2.2",
"babel-plugins": "^1.0.0",
"coffee-loader": "^2.0.0",
"coffeescript": "^2.5.1",
"css-loader": "^5.1.3",
"css-minimizer-webpack-plugin": "^1.3.0",
"jquery": "^3.5.1",
"jquery-blockui": "^2.7.0",
"jquery-ui-dist": "^1.12.1",
"mini-css-extract-plugin": "^1.3.9",
"sass": "^1.32.8",
"sass-loader": "^11.0.1",
"style-loader": "^2.0.0",
"turbolinks": "^5.2.0",
"webpack": "^5.11.0"
},
"version": "0.1.0",
"devDependencies": {
"@webpack-cli/serve": "^1.3.0",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.11.2"
},
"engines": {
"yarn": "1.22.5"
},
"scripts": {
"heroku-prebuild": "echo This runs before Heroku installs dependencies.",
"heroku-postbuild": "echo This runs after Heroku installs dependencies, but before Heroku prunes and caches dependencies",
"heroku-cleanup": "echo This runs after Heroku prunes and caches dependencies."
}
}
和webpacker.yml
# webpacker.yml
# Note: You must restart bin/webpack-dev-server for changes to take effect
default: &default
source_path: app/packs
source_entry_path: entrypoints
public_root_path: public
public_output_path: packs
cache_path: tmp/cache/webpacker
webpack_compile_output: true
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
additional_paths: []
# Reload manifest.json on all requests so we reload latest compiled packs
cache_manifest: false
development:
<<: *default
compile: true
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
https: false
host: localhost
port: 3035
public: localhost:3035
# Inject browserside javascript that required by both HMR and Live(full) reload
inject_client: true
# Hot Module Replacement updates modules while the application is running without a full reload
hmr: false
# Inline should be set to true if using HMR; it inserts a script to take care of live reloading
inline: true
# Should we show a full-screen overlay in the browser when there are compiler errors or warnings?
overlay: true
# Should we use gzip compression?
compress: true
# Note that apps that do not check the host are vulnerable to DNS rebinding attacks
disable_host_check: true
# This option lets the browser open with your local IP
use_local_ip: false
# When enabled, nothing except the initial startup information will be written to the console.
# This also means that errors or warnings from webpack are not visible.
quiet: false
pretty: false
headers:
'Access-Control-Allow-Origin': '*'
watch_options:
ignored: '**/node_modules/**'
test:
<<: *default
compile: true
# Compile test packs to a separate directory
public_output_path: packs-test
production:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile: false
# Cache manifest.json for performance
cache_manifest: true
我终其一生都无法弄清楚现在缺少哪些安装或配置步骤,尤其是当它正在运行时,我不确定发生了什么破坏它?
欢迎提出任何建议。
让我大吃一惊的是,在 https://makandracards.com/makandra/432947-how-to-fix-webpack-dev-server-not-found 上提出建议后
运行 yarn install --check-files 修复这个错误,
我使用 vag运行t 从以管理员身份执行的命令提示符(在 Windows 下)、运行 命令以及我遇到的所有问题重新启动了 VirtualBox VM webpack 和 webpack-dev-server 已解决。
我希望这对某人有所帮助。