Error after running bundle && npm install

I am trying to understand what is happening after I run bundle && npm install. The bundle updates: ‘17 gemfiles dependencies and 69 gems are now installed’ . Then I see

/Users/kevinturney/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/yarn-0.1.1/lib/yarn/server.rb:14:in `<class:Server>': uninitialized constant Socket::SOL_TCP (NameError) from /Users/kevinturney/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/yarn-0.1.1/lib/yarn/server.rb:6:in `<module:Yarn>' from /Users/kevinturney/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/yarn-0.1.1/lib/yarn/server.rb:4:in `<top (required)>' from /Users/kevinturney/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/yarn-0.1.1/bin/yarn:26:in `<top (required)>' from /Users/kevinturney/.rbenv/versions/2.2.3/bin/yarn:23:in `load' from /Users/kevinturney/.rbenv/versions/2.2.3/bin/yarn:23:in `<main>'

and then  several red npm ERR! 's

npm ERR! Failed at the react-webpack-rails-tutorial@0.0.1 postinstall script ‘cd client && yarn install’.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the react-webpack-rails-tutorial package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! cd client && yarn install


What does this NameError mean? I get the same when I start over and run bundle && yarn install too. Subsequently, as I continue with __foreman start -f Procfile.dev__  the server starts and then stops immediately with the following:

22:47:38 web.1 | started with pid 84293
22:47:38 client.1 | started with pid 84294
22:47:38 client.1 | rm: app/assets/webpack/*: No such file or directory
22:47:38 client.1 | /Users/kevinturney/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/yarn-0.1.1/lib/yarn/server.rb:14:in <class:Server>': uninitialized constant Socket::SOL_TCP (NameError) 22:47:38 client.1 | from /Users/kevinturney/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/yarn-0.1.1/lib/yarn/server.rb:6:inmodule:Yarn
22:47:38 client.1 | from /Users/kevinturney/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/yarn-0.1.1/lib/yarn/server.rb:4:in <top (required)>' 22:47:38 client.1 | from /Users/kevinturney/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/yarn-0.1.1/bin/yarn:26:in<top (required)>’
22:47:38 client.1 | from /Users/kevinturney/.rbenv/versions/2.2.3/bin/yarn:23:in load' 22:47:38 client.1 | from /Users/kevinturney/.rbenv/versions/2.2.3/bin/yarn:23:in
22:47:38 client.1 | exited with code 1
22:47:38 system | sending SIGTERM to all processes
22:47:38 web.1 | terminated by SIGTERM ````

Finally, the debug log looks as such:

npm ERR! Darwin 15.6.0
npm ERR! argv “/Users/kevinturney/.nvm/versions/node/v7.1.0/bin/node” “/Users/kevinturney/.nvm/versions/node/v7.1.0/bin/npm” “bugs” “react-webpack-rails-tutorial”
npm ERR! node v7.1.0
npm ERR! npm v4.0.2
npm ERR! code E404

npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/react-webpack-rails-tutorial
npm ERR! 404
npm ERR! 404 ‘react-webpack-rails-tutorial’ is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/kevinturney/react-and-rails/app3/npm-debug.log

It seems that my webpack file is not appearing in app/assets path. 

rm: app/assets/webpack/*: No such file or directory

What can i do?

@kev you have some pretty odd things going on. I’d install the https://github.com/shakacode/react-webpack-rails-tutorial and try to get through that. Keep in mind that the new “generator” for react_on_rails is using yarn and the tutorial is still on npm.

Also, be sure that you have yarn installed. brew install yarn

1 Like

Justin, could it be that I’m using rbenv vs. rvm?

rvm and rbenv are for ruby.

I really don’t know. Sounds like some yak shaving regarding your own setup.

If you need personalized assistance, my team can help. Contact me if so.

Ok here’s the deal. To get this to work for me these were the exact steps i followed. Some of the step were from my class, in addition, i didn’t use git at all on my zillionth attempt.

  1. mkdir testreact/
  2. cd testReact
  3. rails new my_app -d postgresql -T
  4. rails server (test the server — )
  5. rails db:create:all
  6. go to gem file and add – gem “react_on_rails”, “~> 6”
  7. bundle
  8. rails generate react_on_rails:install

This was the fix:
9. go into procfile.dev and change yarn

client: sh -c 'rm app/assets/webpack/* || true && cd client && yarn run build:development'

To npm

web: rails s -p 3000
client: sh -c 'rm app/assets/webpack/* || true && cd client && npm run build:development'
```

and in package.json change yarn to npm

“postinstall”: “cd client && npm install”,

10. bundle && npm install
11. gem install foreman
12. foreman start -f Procfile.dev

 Server starts and Hello Stranger renders!!

You needed to run brew install yarn.

We now recommend yarn.

I just posted a PR to update the tutorial for this:

Thanks Justin,

I’ll try it again with yarn tomorrow.

I ran into a similar error while having the yarn gem installed (a web-server) and its associated executable at the same time that I was running the yarn command for the package manager. Fixing that required gem uninstall yarn and y to remove the executable when prompted.

1 Like