Dmitry Shvetsov
1 min readJul 31, 2018

--

Hi, Trevor.

Since calling .blank? on a string was giving me a NoMethodError

This is due to Rails does not extend theString class. It is strange I never run into this issue but maybe it tailored to how you use the webpacker:check_npm task. I can suggest to use .strip.empty? or stick with your solution and remove all checks after, since you already checked the version. The problem may arise if you will have to check against a complex npm version, 5.5.1 for example.

webpacker requires npm 6.0.0 or greater anyways

🤔 not sure about this. You probably mean node.JS ≥ 6.11.5 as stated here.

~/lib/tasks/../../package.json I fixed this by changing the Pathname.new argument to "#{Rails.root}/package.json" .

Man, this is a nice point! I will change my exanple as well.

I also ran into a strange error where my package.json wasn’t automatically adding the engines object to my package.json after running npm init

I run into this problem a week ago and I have changed the code to .dig method from hashes.

JSON.parse(package_json_path.read).dig(‘engines’, ‘npm’)

I also update the example in the article.

I am happy that the article was useful to you and want to thank you for the helpful feedback!

--

--

Dmitry Shvetsov
Dmitry Shvetsov

No responses yet