rubyonjets / jets

Ruby on Jets
http://rubyonjets.com
MIT License
2.6k stars 181 forks source link

Initial install experience - missing webpack bin stub, `jets build` fails #360

Closed andyatkinson closed 5 years ago

andyatkinson commented 5 years ago

Checklist

My Environment

Software Version
MacOS 10.14.4
Jets 1.8.9 (upgraded to 2.1.2)
Ruby 2.5.3 (upgraded to 2.5.5)
Node 8.11.3 (upgraded to 12.9.1)
NPM 5.6.0 (upgraded to 6.10.2)
Yarn 1.17.3

Expected Behaviour

Hello. I wanted to install Jets locally and play around with it. However unfortunately my initial experience I have had an error with the webpack bin not being present.

This is mostly easily reproducible by running jets build, which I expected to run successfully. I initially found this after creating scaffolding per https://rubyonjets.com/quick-start/ and navigating to localhost:8888/posts expecting to view the posts "index" screen, but instead I get a stack trace and the underlying issue is that webpack is not found.

Current Behavior

jets build fails and says the .bin/webpack is missing in node_modules. I've removed node_modules and re-created it, and listed out the directory contents of node_modules/.bin, and it is indeed not there.

So far I have tried upgrading my node version, and re-running yarn to install the dependencies, and running yarn add webpack which ensures the bin stub is in the node_modules directory, but then I get a different error.

Step-by-step reproduction instructions

I followed the instructions on https://rubyonjets.com/quick-start/. Note that I also have several versions of Rails installed as well and they may be causing a conflict.

Code Sample

Solution Suggestion

Is there any other old versions I could try upgrading? I could also try removing all versions of Rails I have. Any other tips to try? Thanks.

tongueroo commented 5 years ago

Unsure. This may be system-specific or some system setting. Related issues #187 #217 #246

FWIW, here are the versions on my system:

$ node --version
v8.10.0
$ yarn --version
1.9.4
$ npm --version
5.6.0
$ 

Don't believe rails versions has anything to do with it. Thinking if you can get this command working, that'll help:

jets webpacker:compile

That's essentially what webpacker middleware calls on-the-fly in development.

There's also jets new demo --mode api if you don't need assets.

andyatkinson commented 5 years ago

@tongueroo Thanks for the quick response. I'll run through your suggestions and those links, and get back to you on what I find.

andyatkinson commented 5 years ago

@tongueroo I recently installed Rails 6 and am somehow getting this.

~/Projects/demo (master) $ jets webpacker:compile
Webpacker is installed 🎉 🍰
Using /Users/andy/Projects/demo/config/webpacker.yml file for setting up webpack paths
Compiling…
Compilation failed:

/Users/andy/Projects/demo/node_modules/webpack-cli/bin/cli.js:93
                throw err;
                ^

Error: Cannot find module '@rails/webpacker'
Require stack:
- /Users/andy/Projects/demo/config/webpack/environment.js
- /Users/andy/Projects/demo/config/webpack/development.js
andyatkinson commented 5 years ago

@tongueroo Welp, I deleted the application, removed my rails gems, and re-created the demo app with the newer versions of node, nvm, yarn etc. above, and everything is working now. So unfortunately I don't know what the exact cause of the problem was, but webpack is compiling now. I also tried a global install of webpack, which ensured I had a bin for webpack (e.g. which webpack), which may have been the issue. Feel free to close!

$ jets webpacker:compile
Webpacker is installed 🎉 🍰
Using /Users/andy/Projects/demo/config/webpacker.yml file for setting up webpack paths
Compiling…
Compiled all packs in /Users/andy/Projects/demo/public/packs