-
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
Rails erb loader Compile Error #1529
Comments
I think the details should be looked for here. If you are using |
Hi Vill, Thanks for getting back to me! Sorry, just to confirm, should I did try both ways and also tried the rails console method but still getting the same error. Thanks, |
@andybluey, I think the issue is with |
I ran into this issue (i.e. same error message) after running rails-erb-loader does have an issue with poor error messages (see here), which is certainly an obstacle to solving issues like this one, but, if you see this error message, the underlying issue may not be rails-erb-loader itself. First, check the syntax in your erb files for potential compilation issues. Remember that the file is interpreted by erb before the file is interpreted as javascript. I'm using version 3.4.3 of webpacker, and the cause of this issue for me was that webpacker's example erb file hello_erb.js.erb was not erb compilable. The problem was in the javascript comment at the top of the file: // Run this example by adding <%= javascript_pack_tag 'hello_erb' %> to the head of your layout file This has now been corrected in later versions of webpacker (and version 3.5 which is what @andybluey is using) to: // Run this example by adding <%%= javascript_pack_tag 'hello_erb' %> to the head of your layout file Note the double Although, my compilation issue and @andybluey 's issue aren't the same, I'm posting here, in case anyone else seeing the same message has similar compilation related problems. |
I'm facing the same problem. erb-loader fails when there's a call to an asset helper like |
Just going to drop this here since it confounded me. I was getting this error because the erb loader that webpacker:install:erb creates, has the following runner:
In my case, this was running a different version of ruby than I had set up for my rails project. Rails was expecting 2.4.5, and my system ruby was 2.5. Changing the line to specify the correct ruby install fixed the problem
|
- Remove pagy.js.erb file who initiates Pagy on JS - Enable Spring when using webpacker:compile command on travis.yml file From eb-activity.log file --- ERROR in ./app/javascript/packs/hello_erb.js.erb Module build failed (from ./node_modules/rails-erb-loader/index.js): Error: rails-erb-loader failed with code: 1 at ChildProcess.<anonymous> (/var/app/ondeck/node_modules/rails-erb-loader/index.js:128:16) at ChildProcess.emit (events.js:193:13) at maybeClose (internal/child_process.js:999:16) at Socket.stream.socket.on (internal/child_process.js:403:11) at Socket.emit (events.js:193:13) at Pipe._handle.close (net.js:614:12) ERROR in ./app/javascript/lib/pagy.js.erb Module build failed (from ./node_modules/rails-erb-loader/index.js): Error: rails-erb-loader failed with code: 1 at ChildProcess.<anonymous> (/var/app/ondeck/node_modules/rails-erb-loader/index.js:128:16) at ChildProcess.emit (events.js:193:13) at maybeClose (internal/child_process.js:999:16) at Socket.stream.socket.on (internal/child_process.js:403:11) at Socket.emit (events.js:193:13) at Pipe._handle.close (net.js:614:12) usabilityhub/rails-erb-loader#63 rails/webpacker#1560 rails/webpacker#1529
Is this issue still relevant ? Feel free to close it if not 👍 |
Hi All,
I've just included webpacker (inc erb support) to an existing project. I've moved code from the asset pipeline to the example in the docs 'hello_erb.js.erb'.
I can get
console.log('<%= image_tag "logo.svg" %>');
but not
<% helpers = ActionView::Helpers::JavaScriptHelper %> $('.class').html('<%= helpers.escape_javascript(@query) %>');
With the error:
"Failed to compile.
./app/javascript/packs/hello_erb.js.erb
Module build failed: Error: rails-erb-loader failed with code: 1
at ChildProcess. (/Users.../node_modules/rails-erb-loader/index.js:120:16)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
@ multi (webpack)-dev-server/client?http://localhost:3035 ./app/javascript/packs/hello_erb.js.erb"
The error message isn't making it terribly easy to search further.
I've also tried digging through some previous issues that might be related https://github.com/rails/webpacker/issues/1256#issuecomment-367573638 and trying some different loader settings and file headings with no luck.
Let me know if you need anymore info.
Thanks
webpacker '3.5'
rails '5.1.2'
The text was updated successfully, but these errors were encountered: