Using Node.js version 10.9.1, but when I try to run a gulp process that runs node-sass, I get the following error. The npm rebuild node-sass command does nothing because the binary is actually correct. It is node-sass’s incorrect assumption that I’m running node version 8. I thought a path problem was it but running node –version obtains the version 10.9.1.
I end up changing my node version to 10.16.1, removing my node_modules directory, AND removing the package-lock.json file (I think this is key), and then running npm install. This fixed it for one machine but not on another.
Error I was getting
/home/jer0dh/PhpstormProjects/projectdevelopement/node_modules/node-sass/lib/binding.js:15 throw new Error(errors.missingBinary()); ^ Error: Missing binding /home/jer0dh/PhpstormProjects/projectdevelopement/node_modules/node-sass/vendor/linux-x64-57/binding.node Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 8.x Found bindings for the following environments: - Linux 64-bit with Node.js 10.x This usually happens because your environment has changed since running `npm install`. Run `npm rebuild node-sass` to download the binding for your current environment. at module.exports (/home/jer0dh/PhpstormProjects/projectdevelopement/node_modules/node-sass/lib/binding.js:15:13) at Object. (/home/jer0dh/PhpstormProjects/projectdevelopement/node_modules/node-sass/lib/index.js:14:35) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object. (/home/jer0dh/PhpstormProjects/projectdevelopement/node_modules/gulp-sass/index.js:162:21) jer0dh@jer0dh-ThinkPad:~/PhpstormProjects/projectdevelopement$ node --version v10.9.0 jer0dh@jer0dh-ThinkPad:~/PhpstormProjects/projectdevelopement$ nvm use 10.16.1 Now using node v10.16.1 (npm v6.9.0)
UPDATE: The above worked for one machine but on another freshly installed linux Mint 19.2 workstation using Visual Code, the above did not help. Found possible solutions: https://stackoverflow.com/questions/44700432/visual-studio-code-to-use-node-version-specified-by-nvm
But it is happening in both the regular terminal and the Visual Code terminal. The path looks right.
I am wondering how node-sass determines the current version of node.
$ node --version v10.16.1
It looks like it is getting it from /usr/bin
$ /usr/bin/node --version v8.10.0
Yet the PATH shown above clearly shows it should be going directly to nvm node path first.
$ /home/jer0dh/.nvm/versions/node/v10.16.2/bin/node --version v10.16.1
Without digging deeper down this rabbit hole. Let’s try to update this Linux Mint 19.2 distro with node 10.x using
Unfortunately, Mint 19.2 “tina” is not supported yet. Only up to 19 “tara”. Added the nodesource tara repository, but getting:
E: The repository 'https://deb.nodesource.com/node_10.x tara Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default.
Notice there is a
nodejs file in
/usr/bin that is a pointer to
/usr/bin/node. If I remove the
nodejs file, gulp reports:
$ gulp /usr/bin/gulp: 2: /usr/bin/gulp: /usr/bin/nodejs: not found
If I try to create
/usr/bin/nodejs pointing to the v10.16.1
node file, gulp will not work but with a different error.
$ sudo ln -s /home/jer0dh/.nvm/versions/node/v10.16.1/bin/node nodejs $ gulp internal/modules/cjs/loader.js:638 throw err; ^ Error: Cannot find module 'gulp-util' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18)
If I copy
/usr/bin, I get the same error above running gulp.
Maybe what happened is that when I installed this box, I may have installed
sudo apt install gulp which probably installed the 8.x version of node to
As a test I installed Linux Mint Mate 19.0 ‘Tara’ and installed node using only
nvm: https://nodesource.com/blog/installing-node-js-tutorial-using-nvm-on-mac-os-x-and-ubuntu/ and installed
gulp using only
npm install --global gulp-cli. I confirmed that neither
gulp were in the
I cloned my project to a directory and ran
npm install and then when I ran
gulp, it actually worked.
The Solution for me
I went back to my Linux Mint 19.2 install and ran the following to clear out the apt-get installed gulp and node.
sudo apt-get remove gulp sudo apt-get remove nodejs sudo apt-get autoremove
I made sure I installed gulp the correct way:
npm install --global gulp-cli
I also made sure node still worked because it is still installed via
Tried out my normal node-sass gulp tasks and….