webpacker未在rails 4.2上成功安装

时间:2017-11-27 01:35:01

标签: ruby-on-rails node.js webpacker

终端:在Windows 10上的Ubuntu上进行bash Rails:4.2.8 npm:5.5.1 node:v8.9.1 纱线:1.3.2

rake webpacker:install之后,控制台显示如下。虽然它在最后显示“已成功安装”,但日志中会出现一些错误。这是正常的吗?

  create  config/webpacker.yml
Copying webpack core config and loaders
  create  config/webpack
  create  config/webpack/development.js
  create  config/webpack/environment.js
  create  config/webpack/production.js
  create  config/webpack/test.js
Copying .postcssrc.yml to app root directory
  create  .postcssrc.yml
Copying .babelrc to app root directory
  create  .babelrc
Creating javascript app source directory
   exist  app/javascript
   identical  app/javascript/packs/application.js
Installing binstubs
     run  bundle binstubs webpacker from "."
  append  .gitignore
Installing all JavaScript dependencies
     run  yarn add @rails/webpacker coffeescript@1.12.7 from "."
yarn add v1.3.2
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.1.3: The platform "linux" is incompatible with this module.
info "fsevents@1.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "@rails/webpacker > postcss-cssnext@3.0.2" has unmet peer dependency "caniuse-lite@^1.0.30000697".
error An unexpected error occurred: "EINVAL: invalid argument, lstat '/mnt/d/Github/cfegame/node_modules/babel-core/package-lock.json'".
info If you think this is a bug, please open a bug report with the information provided in "/mnt/d/Github/cfegame/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Installing dev server for live reloading
     run  yarn add --dev webpack-dev-server from "."
yarn add v1.3.2
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.1.3: The platform "linux" is incompatible with this module.
info "fsevents@1.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "webpack-dev-server > webpack-dev-middleware@1.12.1" has unmet peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0".
warning " > webpack-dev-server@2.9.4" has unmet peer dependency "webpack@^2.2.0 || ^3.0.0".
error An unexpected error occurred: "EINVAL: invalid argument, lstat '/mnt/d/Github/cfegame/node_modules/camelcase-keys/node_modules/camelcase/license'".
info If you think this is a bug, please open a bug report with the information provided in "/mnt/d/Github/cfegame/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Webpacker successfully installed  

当我“成功安装”webpacker并且我想检查webpack-dev-server是否正常工作时,控制台显示如下。这是否意味着我没有正确安装webpacker?

(home_dir)/.rvm/gems/ruby-2.3.3/gems/webpacker-3.0.2/lib/webpacker/dev_server_runner.rb:47:in `exec': No such file or directory - (project_dir)/node_modules/.bin/webpack-dev-server (Errno::ENOENT)
        from (home_dir)/.rvm/gems/ruby-2.3.3/gems/webpacker-3.0.2/lib/webpacker/dev_server_runner.rb:47:in `block in execute_cmd'
        from (home_dir)/.rvm/gems/ruby-2.3.3/gems/webpacker-3.0.2/lib/webpacker/dev_server_runner.rb:46:in `chdir'
        from (home_dir)/.rvm/gems/ruby-2.3.3/gems/webpacker-3.0.2/lib/webpacker/dev_server_runner.rb:46:in `execute_cmd'
        from (home_dir)/.rvm/gems/ruby-2.3.3/gems/webpacker-3.0.2/lib/webpacker/dev_server_runner.rb:11:in `run'
        from (home_dir)/.rvm/gems/ruby-2.3.3/gems/webpacker-3.0.2/lib/webpacker/runner.rb:6:in `run'
        from (home_dir)/.rvm/gems/ruby-2.3.3/gems/webpacker-3.0.2/exe/webpack-dev-server:8:in `<top (required)>'
        from bin/webpack-dev-server:17:in `load'
        from bin/webpack-dev-server:17:in `<main>'

1 个答案:

答案 0 :(得分:1)

基本上yarn正在管理你的包。他正在尝试使用webpack-dev-server-安装yarn add --dev webpack-dev-server from ".",但它失败了。这是关于yarn add command

的文档

npm是使用yarn安装软件包的替代方法,因此在服务器终端中运行

npm install webpack-dev-server

它应该安装依赖项

  

当我成功安装&#34; webpacker我想检查webpack-dev-server是否正常工作,控制台显示如下。这是否意味着我没有正确安装webpacker?

(home_dir)/.rvm/gems/ruby-2.3.3/gems/webpacker-3.0.2/lib/webpacker/dev_server_runner.rb:47:in `exec': No such file or directory - (project_dir)/node_modules/.bin/webpack-dev-server (Errno::ENOENT)

你要么没有安装它,要么你正在寻找错误的路径,也许gem已经安装在.rvm/gems/ruby-2.3.3somethingelse

您可能想要阅读的一些讨论

https://github.com/Microsoft/WSL/issues/2448

https://github.com/yarnpkg/yarn/issues/4188