首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >"webpack“指挥部未找到

"webpack“指挥部未找到
EN

Stack Overflow用户
提问于 2021-04-20 04:37:35
回答 1查看 1.6K关注 0票数 1

我已经为我的Rails 6.1项目安装了webpack

代码语言:javascript
复制
    yarn add webpack
    yarn add -D webpack-cli
    yarn add @rails/webpacker@6.0.0-beta.6
    bin/rails webpacker:install

直到最近,一切都很完美,但现在我发现了错误。

代码语言:javascript
复制
error Command "webpack" not found.

每当我执行下列任何一项时:

代码语言:javascript
复制
./bin/webpack
./bin/webpack-dev-server
yarn run webpack

我假设这是纱跑webpack,它是运行在“下盖”的webpack bin命令,因为我得到了完全相同的输出对所有三个命令:

代码语言:javascript
复制
yarn run v1.22.5
error Command "webpack" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

正在运行

代码语言:javascript
复制
bundle info webpacker 
yarn list --pattern @rails/webpacker

这两个版本都显示我安装了beta.6版本的webpacker

我有package.json

代码语言:javascript
复制
# 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

代码语言:javascript
复制
# 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

我不知道我的生活现在缺少什么安装或配置步骤,特别是因为这是工作的,我不知道发生了什么事来打破它?

欢迎任何建议。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-20 12:04:23

让我感到惊讶的是,下面是关于https://makandracards.com/makandra/432947-how-to-fix-webpack-dev-server-not-found的一个建议:

运行纱线安装-检查文件以修复此错误,

我使用命令提示符重新启动了VirtualBox VM,命令提示符作为管理员执行(在Windows下),运行该命令,并且解决了webpack和webpack-dev服务器的所有问题。

我希望这能帮到别人。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67172533

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档