-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the .nvmrc file to facilitate the use of nvm. #138
Conversation
With .nvmrc the Node Version Manager (nvm) can be used to manage the NodeJS version dependency. Dependencies introduced in the package.json file have an implicit restriction on which NodeJS version(s) they can be used. The .nvmrc file makes this restriction explicit. After installing nvm you can make use of this file by executing the following commands: ``` $ nvm install $ nvm use ``` This installs and activates the correct NodeJS version for the project. After this `npm install` and `gulp` should work without a hitch.
You now set the version at 10?
I wonder how we should roll-out updates of next NodeJS version if there is a hard coded version string in the project? |
Yes, the .nvmrc file sets the NodeJS version to 10.16.0 when nvm is used ( The need for this arose when I tried to install the NodeJS modules to run Gulp. libsass fails to compile on macOS when attempting to install this version of the node-sass package on newer versions of Node (v. 12.12.0 in my case). Here are the errors thrown by node-gyp:
As is visible here, the V8 runtime is not compatible with the header files provided by libsass, which means that there is a mismatch between the runtime version expected by libsass and the one provided by NodeJS 12. This can be remedied by using an older version of NodeJS - in this case version 10.16.0 seems to do the trick. The only way to have at least some chance of providing reproducible builds across different environments with NodeJS is to lock down both the package dependecy versions and the runtime version. Locking down package dependency versions simply isn't enough. If I understood correctly, you expect the Gulp workflow to be executed on the VM, right? I see this as a complication - especially when considering running this stuff ın Docker containers. Also, I think it would be good to separate the development workflow from the execution context to better emulate the actual production environment - it is, after all, a kind of deployment target. I'm not sure I understand your comment on rolling out updates. It is, of course, possible to run nvm on the VM. The fact that the VM has a newer version of NodeJS installed by default should cause no problems. Sorry for such a long comment! :) |
I think the root problem here is that you were unable to run gulp/node-sass due to some other reason, maybe outdated dependencies. There is one gulp/node-sass already preinstalled, as well is the NodeJS LTS version. They are broadly compatible and allow for smooth upgrades. If one needs to revert to downgrading NodeJS then it risks causing problems for everything else that is installed. Related: #128 (comment) |
Hmm... Nope. The reason is the one I described earlier but I guess the way to go is just run Gulp on the VM. As I pointed out, I ran into the problem when I was setting up the asset pipeline to run on the macOS host, not the guest VM. (I usually prefer running asset pipelines natively for performance, transparency and portability reasons) Regarding screwing things up with nvm: Using nvm is actually really safe as it installs packages in a version-specific container. You use nvm to automatically switch between multiple NodeJS runtime versions. It's not downgrading, It's dependency management. |
OK, thanks for the feedback. We'll consider it.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Feel free to rebase and merge. We might bump it to 12.8.2
as that is what the development environment is currently shipped with.
You might need to rebase on master and force push to get the Travis CI to accept the merge.
Continuing this in #186 |
With .nvmrc the Node Version Manager (nvm) can be used to manage
the NodeJS version dependency. Dependencies introduced in the
package.json file have an implicit restriction on which NodeJS
version(s) they can be used. The .nvmrc file makes this restriction
explicit.
After installing nvm you can make use of this file by executing the
following commands:
This installs and activates the correct NodeJS version for the
project. After this
npm install
andgulp
should work withouta hitch.