gpt4 book ai didi

ruby-on-rails - Rails : Vanilla Rails 6. 0 错误命令 "webpack"未找到

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

系统:

ruby :2.6.3p62 (rvm)
rails :6.0
操作系统:macOS 10.14.6

设置

一个全新的 Rails 6.0 应用程序:

$ rails new testshop2
$ cd testshop2
$ rails g controller Page index
$ rails s
=> Booting Puma
=> Rails 6.0.0 application starting in development
=> Run `rails server --help` for more startup options
Puma starting in single mode...
* Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop

当我浏览到` http://localhost:3000/page/index ' 系统通过此错误:
Started GET "/page/index" for ::1 at 2019-09-23 17:06:12 +0200
(0.4ms) SELECT sqlite_version(*)
Processing by PageController#index as HTML
Rendering page/index.html.erb within layouts/application
Rendered page/index.html.erb within layouts/application (Duration: 1.8ms | Allocations: 206)
[Webpacker] Compiling…
[Webpacker] Compilation failed:
error Command "webpack" not found.

Completed 500 Internal Server Error in 2021ms (ActiveRecord: 0.0ms | Allocations: 640080)



ActionView::Template::Error (Webpacker can't find application in /Users/stefan/Github/sandbox/testshop2/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
}
):
6: <%= csp_meta_tag %>
7:
8: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
9: <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
10: </head>
11:
12: <body>

app/views/layouts/application.html.erb:9

我怎样才能解决这个问题?它说 error Command "webpack" not found.但是 Rails 不应该自动安装所有需要的东西吗?

最佳答案

在尝试设置新的 时,我不得不面临同样的挑战 rails 6 申请 Ubuntu 20.04 .
当我启动 Rails 服务器时,我收到错误:

error Command "webpack" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
09:17:58 webpacker.1 | exited with code 1
09:17:58 system | sending SIGTERM to all processes
09:17:58 watcher.1 | exited with code 1
09:17:58 web.1 | terminated by SIGTERM
这是我修复它的方法 :
对我来说,问题是由于互联网连接不佳,导致无法完整安装 webpacker及其所有依赖项。所以每次我运行命令时:
bundle exec rails webpacker:install
我得到这个输出:
Installing all JavaScript dependencies [4.3.0]
run yarn add @rails/webpacker@4.3.0 from "."
yarn add v1.22.5
[1/4] Resolving packages...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
我只需要搬到互联网连接更好的区域,然后运行命令:
bundle exec rails webpacker:install
或者
rails webpacker:install
这次运行成功,安装了 webpacker及其所有依赖项,它给了我这个最终输出:
[4/4] Building fresh packages...
success Saved 1 new dependency.
info Direct dependencies
└─ webpack-dev-server@3.11.0
info All dependencies
└─ webpack-dev-server@3.11.0
Done in 5.90s.
就这样。
我希望这会有所帮助

关于ruby-on-rails - Rails : Vanilla Rails 6. 0 错误命令 "webpack"未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58065428/

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