paliarush / magento2-vagrant-for-developers

Vagrant Box for Magento 2 Developers
MIT License
447 stars 165 forks source link

Node Version and Provisioning #161

Closed nfourteen closed 6 years ago

nfourteen commented 7 years ago

I just created a new project with this box and installed Magento 2.2. I'm trying to set up Grunt and I get errors like the following:

npm WARN engine sntp@2.1.0: wanted: {"node":">=4.0.0"} (current: {"node":"v0.10.25","npm":"1.3.10"})
npm WARN engine cryptiles@3.1.2: wanted: {"node":">=4.0.0"} (current: {"node":"v0.10.25","npm":"1.3.10"})
npm WARN engine boom@4.3.1: wanted: {"node":">=4.0.0"} (current: {"node":"v0.10.25","npm":"1.3.10"})
npm WARN engine hoek@4.2.0: wanted: {"node":">=4.0.0"} (current: {"node":"v0.10.25","npm":"1.3.10"})
npm WARN engine har-schema@2.0.0: wanted: {"node":">=4"} (current: {"node":"v0.10.25","npm":"1.3.10"})

I can't find where Node is provisioned on this box and the version from a fresh install is v0.10.25. The current stable version of Node is 8.9.1. Is Node provisioned or was it installed on the base box and that's why it's out of date?

nfourteen commented 7 years ago

I originally thought I could't set up Grunt because of the Node version warnings breaking the install. It seems it's related to phantomjs-prebuilt@2.1.16. See New project trying to install phantom-prebuilt @2.1.11 and getting errors #599.

Here's my error output:

> phantomjs-prebuilt@2.1.16 install [install-location]/magento2ce/node_modules/phantomjs-prebuilt
> node install.js

[install-location]/magento2ce/node_modules/phantomjs-prebuilt/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js:5
const Hoek = require('hoek');
^^^^^
SyntaxError: Use of const in strict mode.
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> ([install-location]/magento2ce/node_modules/phantomjs-prebuilt/node_modules/request/node_modules/hawk/lib/index.js:5:33)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! weird error 8
npm ERR! not ok code 0

Still trying to figure out a work around, but I don't believe this is a Node version issue on the box anymore.

nfourteen commented 7 years ago

I was able to get Grunt up and running by installing nvm and Node version 8.9.1 per @hwinn4's comment.

These were the commands I used after installing nvm on the box per nvm instructions.

nvm install 8.9.1
nvm use system
npm ls -g --depth 0 // needed to get preinstalled globals
nvm use 8.9.1
npm install -g grunt-cli@1.2.0 // preinstalled system global
npm install -g gulp@3.9.1 // preinstalled system global
npm install

Still not sure if the box has an old Node version on it or if phantomjs-prebuilt@2.1.16 is pulling in the legacy binary.

paliarush commented 6 years ago

@nfourteen the box has all tools pre-installed so your point is correct that they may be outdated.

I'm not a front-end developer and do not use those tools so would really appreciate if you could provide a PR with the fix. Upgrade can be done in a way similar to varnish upgrade

Do you think you would be able to create PR? From my side I can run the tests for your PR branch before accepting it.

nfourteen commented 6 years ago

@paliarush Sorry it's taken a while to respond. I've been working on this and will create a PR, just running some more tests to make sure there are no permission issues and there's compatibility with older versions of Magento's package.json config file.

paliarush commented 6 years ago

@nfourteen Merged PR, thank you.