添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account Webpacker can't find application.js in D:/ROR/blog/public/packs/manifest.json in Ruby on Rails 6.1 #2825 Webpacker can't find application.js in D:/ROR/blog/public/packs/manifest.json in Ruby on Rails 6.1 #2825 youthtech-228 opened this issue Dec 23, 2020 · 20 comments

I am new in Rails 6. I followed their document( https://guides.rubyonrails.org/getting_started.html ) but I had some errors related to webpacker.
I made a route on routes file(config/routes.rb)

Rails.application.routes.draw do
  get "/articles", to: "articles#index"
  # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html

And I created ArticlesController and its index action
bin/rails generate controller Articles index --skip-routes

And I run the server

bin/rails server

when I visit http://localhost:3000/articles, this error happend.

Webpacker::Manifest::MissingEntryError in Articles#index
Showing D:/ROR/blog/app/views/layouts/application.html.erb where line #10 raised:
Webpacker can't find application.js in D:/ROR/blog/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:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.7.2'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.1.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
# Use Puma as the app server
gem 'puma', '~> 5.0'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 5.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Active Storage variant
# gem 'image_processing', '~> 1.2'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.4', require: false
group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 4.1.0'
  # Display performance information such as SQL time and flame graphs for each request in your browser.
  # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
  gem 'rack-mini-profiler', '~> 2.0'
group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 3.26'
  gem 'selenium-webdriver'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
          

I think you can solve it by installing the gem from the master branch
gem 'webpacker', git: 'https://github.com/rails/webpacker.git

But I would like to avoid this route.

Hello @youthtech-228 ! 👋

I don't have much details about your problem, but I guess (looking your printscreen) this error is occuring with you because you did not compile the assets yet. Or you dont have created the file app/javascript/packs/application.js.

Could you try execute rails webpacker:compile and refresh the page to check if the error persists? This error is commonly related to this.

If the error persist, please let me know, and then we can get some more informations to investigate the root cause 🔍

Thanks! 🤝

@youthtech-228 @Destinyspell189 If is possible, could you provide to us a reproducible repo that occurs this error on it?

Sorry, I really didn't understand well the situation yet 🙈 But with the repo, it will be more easy to help you guys 🤝

Anyway, thanks for report! Any additional details about this (example: environment, OS version, ruby version, and so on) will be welcome 🏆

Hello @youthtech-228 ! 👋

I don't have much details about your problem, but I guess (looking your printscreen) this error is occuring with you because you did not compile the assets yet. Or you dont have created the file app/javascript/packs/application.js.

Could you try execute rails webpacker:compile and refresh the page to check if the error persists? This error is commonly related to this.

If the error persist, please let me know, and then we can get some more informations to investigate the root cause 🔍

Thanks! 🤝

Thanks

Hello @youthtech-228 ! 👋

I don't have much details about your problem, but I guess (looking your printscreen) this error is occuring with you because you did not compile the assets yet. Or you dont have created the file app/javascript/packs/application.js.

Could you try execute rails webpacker:compile and refresh the page to check if the error persists? This error is commonly related to this.

If the error persist, please let me know, and then we can get some more informations to investigate the root cause 🔍

Thanks! 🤝

The readme says to place the files in app/packs, not app/javascript/packs.

I ended up finding a fix for my issue through this link: https://discuss.rubyonrails.org/t/pretty-astonishing/76850

I don't know if you are running into the same issue but it is worth a shot and maybe anyone else who stumbles here might find it useful. It seems that upon using the default installation process for RoR, it grabs a beta version of webpacker and you hit all kinds of issues because of it. Ross Kaffenberger understood the issue better so check out the link to read more from him but here were the steps to fix the issue:

$ yarn remove @rails/webpacker
$ rm -rf ./node_modules
$ yarn add @rails/webpacker@^5.2.1

Hopefully it works or helps anyone else who is struggling.

EricBollar, Forison, kvo92, ciromine, ScarletTanager, Brunlo, jsgovea, DrewAPeterson7671, rafaelmontas, and QueeniePeng reacted with thumbs up emoji LoboRich, ScarletTanager, Brunlo, jsgovea, vyhlidal, and gigooo-member reacted with heart emoji All reactions

yarn remove @rails/webpacker
returned cannot find webpacker
but then I ran yarn add @rails/[email protected]
it exited with error error

/home/fixed/Desktop/deep_rails/node_modules/node-sass: Command failed.

but surprising enough my website started working

yarn remove @rails/webpacker
returned cannot find webpacker
but then I ran yarn add @rails/[email protected]
it exited with error error

/home/fixed/Desktop/deep_rails/node_modules/node-sass: Command failed.

but surprising enough my website started working

that worked for me! Thank you so much, @anasaijaz ! 💯

If you are facing this issue with error logs like this:

[Webpacker] Compiling...
[Webpacker] Compilation failed:
node:internal/crypto/hash:67
  this[kHandle] = new _Hash(algorithm, xofLen);
Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at module.exports (/home/hoseon/rails/blog/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/home/hoseon/rails/blog/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/home/hoseon/rails/blog/node_modules/webpack/lib/NormalModule.js:471:10)
    at /home/hoseon/rails/blog/node_modules/webpack/lib/NormalModule.js:503:5
    at /home/hoseon/rails/blog/node_modules/webpack/lib/NormalModule.js:358:12
    at /home/hoseon/rails/blog/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/home/hoseon/rails/blog/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at iterateNormalLoaders (/home/hoseon/rails/blog/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
    at /home/hoseon/rails/blog/node_modules/loader-runner/lib/LoaderRunner.js:236:3
    at context.callback (/home/hoseon/rails/blog/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at /home/hoseon/rails/blog/node_modules/babel-loader/lib/index.js:59:71 {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
Node.js v17.2.0

Downgrade your Node to 16

I had the same ERR_OSSL_EVP_UNSUPPORTED error when running my RSpec tests on github CI. Adding NODE_OPTIONS='--openssl-legacy-provider' in my .github/workflows/ci.yml fixed the issue.

steps: - name: Checkout code uses: actions/checkout@v3 - name: Install Ruby and gems uses: ruby/setup-ruby@v1 with: bundler-cache: true - name: Install packages uses: borales/actions-yarn@v4 with: cmd: install - name: Load schema run: bin/rails db:schema:load - name: Run specs run: NODE_OPTIONS='--openssl-legacy-provider' bundle exec rspec spec

babel.config.js change

Replace this : '@babel/plugin-proposal-private-methods', with '@babel/plugin-transform-private-methods',

terminal :
export NODE_OPTIONS=--openssl-legacy-provider

package.json change :

"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"webpack-dev-server": "^3"

rm -rf node_modules
rails assets:clobber
rails assets:precompile

yarn remove @rails/webpacker returned cannot find webpacker but then I ran yarn add @rails/[email protected] it exited with error error

/home/fixed/Desktop/deep_rails/node_modules/node-sass: Command failed.

but surprising enough my website started working

@anasaijaz, Thank you! I faced the same problem. My ruby application '2.7.1', rails 6.1.7.6. Although I tried many other ways but to no avail.
And only your tutorial works for me! Thank you!