small medium large xlarge

Generic-user-small
26 Nov 2016, 22:08
Kemory Grubb (7 posts)

Hello David, great book.

This is my 3rd time picking up this book to start the project, each time before either an issue with Psql or the JS part cause me give up.

Today I started again, only to be held up by Foreman not starting webpack. When I run foreman start I get this error 21:43:53 webpack.1 | unknown command: ./node_modules/.bin/webpack-dev-server --config config/webpack.config.js

I tried googling but I can’t find anything specific. Can you help me with this error? Also, I am running Ubuntu 14 via Vagrant.

Dmfcb_pragsmall
26 Nov 2016, 22:32
David Copeland (476 posts)

The error means that the command ./node_modules/.bin/webpack-dev-server cannot be found. From the directory where you are running the app, what happens when you do ls ./node_modules/.bin/webpack-dev-server

If that’s missing, you may not have installed Webpack or may have installed incorrectly.

On page 9, the book says to do bundle exec rails generate webpack_rails:install

Part of what that does is into install Webpack, but you must say “yes” when asked if you want it to run npm install for you.

If you missed any of that, look at package.json and see if webpack is in there. If it is, run npm install and then start over with the ls. If not, I would recommend you run the rails generator bundle exec rails generate webpack_rails:install and see if that fixes it.

Generic-user-small
27 Nov 2016, 18:52
Kemory Grubb (7 posts)

Thanks for your response.

My .bin folder was empty. I think it is because I ran npm install command with the --no-bin-links argument. I did because I was getting a ERR! EPROTO: protocol error, symlink '../acorn/bin/acorn' -> '/vagrant/Rails/rShine/node_modules/.bin/acorn' error.

I got the solution from [https://github.com/npm/npm/issues/12733](https://github.com/npm/npm/issues/12733)

Generic-user-small
27 Nov 2016, 19:41
Kemory Grubb (7 posts)

I finally got foreman to work by running Vagrant as an admin on my PC. The .bin folder now have the appropriate symlinks.

Now I have new problems…

Because I am using Vagrant for my Rails development, I access rails server by binding it to the ip address of vagrant box, this is 192.168.111.222

So I can access the rais app by visiting 192.168.111.222:3000 in my desktop. However I cannot access the webpack-dev-server at http://localhost:3808/webpack/

Generic-user-small
27 Nov 2016, 21:44
Kemory Grubb (7 posts)

I finally fixed the last error by adding config.webpack.dev_server.host = proc { request.host } to my developement.rb file and binding rails server and webpack-dev-server to 0.0.0.0

It took me only 2 days to configure WebPack. This is why I have been avoiding JS frontend frameworks like the plague. This is why laugh when devs try to extol the virtues of “modern” JS ecosystem.

Dmfcb_pragsmall
27 Nov 2016, 22:04
David Copeland (476 posts)

Yeah, I hear you. That said, most of this stuff is assuming you are doing development on a laptop and not in a VM. Using a VM makes things much more complicated and requires you to understand things at a more detailed level just to have basic functionality working. Every time I’ve added them (or Docker) to my dev setup, I lose days just getting back to where I was.

Generic-user-small
28 Nov 2016, 19:14
Kemory Grubb (7 posts)

Honestly, I beg to differ because of 1 fact; your book was released in 2016 and if someone takes it up in 2017, every piece of JS will be outdated. Running through the JS sections of your book in 2018 will be next to impossible. The transient nature of the modern JS ecosystem puts a 18 month shelf life on your book. Irrespective of me using a MacBook, ThinkPad or a Surface Book.

This why I can’t or don’t want to take JS frontend development serious. Before I got this book I was questioning your choice of sticking with AngularJS 1 because I have the previous version. Had I waited till this time next year I would be asking why you chose the older Angular, NPM and WebPack, because WebPack and NPM will have been replaced by something newer.

Today I will begin to soldiering through adding CSS and webfonts to WebPack. Let’s see what new surprises the JS ecosystem has in store.

Dmfcb_pragsmall
28 Nov 2016, 19:30
David Copeland (476 posts)

Yeah, partway through, yarn was released and I thought about moving to that. JS is constantly moving and I don’t get why. Definitely would think twice writing a JS-based book again :)

Generic-user-small
29 Nov 2016, 18:40
Kemory Grubb (7 posts)

Yeah… that’s what I was trying to get at… you are so brave for writing a book that depends on the current JS ecosystem.

The only reason I am pushing through the JS nightmare is because I am really interested in seeing how to decouple the view layer from Rail’s MVC. Once I have that down, I may push on to picking one of the JS frameworks, which most likely will be VueJS. It is the only one that made sense at first glance of the 3 dozen JS frameworks I’ve looked at.

Thanks for time and all the best with your future endeavours.

You must be logged in to comment