-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
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
Javascript not executing? #2955
Comments
Hi @dmbrooking ! 👋 Can you provide us a reproducible repo with this situation? If so, it will be possible to help you in a more assertive way 🍻 |
Hi @pedrofurtado.. thanks for the quick response. Here you go: https://github.com/dmbrooking/webpacker_test I went ahead and created a brand new Rails application with Then I created a branch and a PR, dmbrooking/webpacker_test#1 where you can see the steps I took. I followed this: https://github.com/rails/webpacker/blob/master/6_0_upgrade.md It is not working there. Let me know if you need any more info. |
Same issue +1 |
same issue +1 webpacker.yml.txt |
Please make sure the gem versions and NPM packages are identical @dmbrooking Thanks for the sample repo. Looking through the changeset, it appears that your Webpacker gem and Following the UPGRADE instructions appears to result in installing I think it would be better to link to the releases page and say something to the effect of "get the latest release."
|
Solved by replacing this but in upgrade guide upgrade guide written
|
@Elsopuro If you upgrade to the latest versions of both the gem and the NPM package (6.0.0.beta.6 as of this note) then you'll want to undo that change. |
@rossta fix that issue. thks |
I got the same issue firstly, and I fixed it with @rossta 's reply. BTW, in gem, if you config |
I think I am having the same problem as everyone else here but cant really tell what I need to do from the commentary above. I have just upgraded my webpacker gem to beta,6 but have tried so many other things I am not sure where I am at. I am using Rails 6.1 and most of my "Javascript" is in .coffee files. I even tried renaming application.js to application.coffee and reformatting but that didnt work either. My Gemfile has
I have done the following"
Then in webpacker 6 style configured as follows:
and
This is all a mish-mash of attempts from a number of sources including this post https://stackoverflow.com/questions/57555708/rails-6-how-to-add-jquery-ui-through-webpacker, https://github.com/rails/webpacker and others. By the way, I am trying to migrate Coffescript from Rails 5 and so this makes extensive use of the JQuery $ global. Any help much appreciated. |
First, let's make sure you're using the right gem and NPM versions. As of right now, using the pessimistic version constraint with the webpacker gem will not install the latest beta. See #2940 for more info. Run If not, you'll need to fix it: Try changing
To the following and bundle update.
To get your NPM package on the right version, run
Start there and that may get things working. If not, then revisit the UPGRADE.md docs to doublecheck the rest of the steps. |
@rossta sorry for the delay in getting back to you but it was the mismatch of versions. I'm good now. I didn't even notice that. Thanks! |
@rossta - thanks, I think that was it, not having the matching beta.6 yarn version of webpacker installed. I did also seemingly have to do the following:
and:
I dont know if that is consistent with your expectations? Commenting any of the above out meant that some kind of error was returned when executing Javascript - maybe I am missing something else? Anyway, it does all seem to be working now so thanks! |
Having the same issue, resolved with solution from #2955 (comment). |
* chore: upgrade to webpacker 6 * chore(FIX): fixing webpacker gem version as stated in rails/webpacker#2955 (comment) * chore: add tailwind and postcss * chore: remove sass-rails * chore: remove sprockets * chore: add webpack dev server to procfile use hivemind process manager https://github.com/DarthSim/hivemind * fix: update gemfile.lock * chore: remove webpack compile in test * chore(ga): add webpack build * chore(ga): add rails_env
struggled with issue rails/webpacker#2955 for entirely too long
In the mean time, I've used the next hack to make sure it never reproduces in my codebase: IO.foreach("package.json").find { |line| line[%r("@rails/webpacker"\s*:\s*"(.*?)")]}
gem "webpacker", Regexp.last_match(1).tr("-", ".") It feels like there should be a way |
i resolved this issue by using github repo as gem source |
Version pickup issue fixed with 6.0.0.rc1. |
In my case I had to run |
I really think this must be something really dumb and am hoping it's an easy fix.
I was having issues with mini-css-extract-plugin and undefined 'tap' method, but everything else was working fine. After some research, I saw the 6_0_upgrade.md doc so figured I'd try that. It did fix my CSS issue but now my Javascript won't execute in the browser, even though it compiles just fine.
I have stripped my application.js down so it is JUST a console.log statement.
I've included this via
<%= javascript_pack_tag "application" %>
.When I browse to a page, I can see in dev tools sources tab that it has loaded.
However, it just isn't console.logging anything. What could I be missing? This worked before going from webpacker 5.x to 6.0.
The text was updated successfully, but these errors were encountered: