Grunt can't run because: Error: Module did not self-register - node.js

I use the same project for two machines. I can use Grunt on my iMac with npm 1.4.28 and can't run Grunt with my other machine npm -v 2.5.1
How can I revert my version of npm back to previous version? What if that particular version is not available?

So #steveax was correct, it was a compatibility issue. A few other people experienced the same thing. The repository author issued a great solution, though I would like to see the module and npm latest versions be compatible. But this works now:
On Linux or Mac:
NPM install -g n
n 0.10.33
On Windows:
npm install -g nvmw
nvmw install v0.10.33
nvmw use v0.10.33

what steveax in his comment answered is probably right!
but to answer your question, the crazy stuff about npm is that you can use npm itself to change the version:
$ npm install -g npm#1.4.28

Related

npm -v still showing version 2.x.x after installing npm3

I am starting to use Angular 2, which requires npm 3.x.x, so I installed it with npm install -g npm3. The Angular 2 tutorials tell me to verify that I have npm 3.x.x by running npm -v, however when I run that, it still says I have version 2.15.8. It shows that I have version 3.10.7 if I run npm3 -v, but not if I run npm -v. Is this going to cause errors? Do I need to it to say I'm using version 3.x.x when I run npm -v? If so, what do I need to do?
EDIT:
Node.js version: node -v reveals that I am using v4.4.7 (Angular2 requires something between 4.4.x - 5.x.x, so I should be good here)
OS: I am currently using Windows 10 on a PC, but have had the same issue with my Mac.
Upgrade npm using this command - npm install -g npm
Maybe this helps:
https://www.google.de/search?q=update+npm+windows
Updating npm with npm itself will store npm.cmd in ../appdata/roaming/.
To avoid conflicts with an older npm version you need to remove npm.cmd from C:\Program Files\nodejs\npm.cmd

libsass bindings not found when using node-sass in nodejs

I want to use the node-sass module in my node.js v0.12 application to benefit from the performance of libsass.
I executed npm i node-sass to install the module, no errors so far.
Now the mess starts:
If I just open the REPL in a terminal to try out node-sass then everything works fine but if I include it in my project files and run node myfile.js then I get the following error message:
Error: `libsass` bindings not found. Try reinstalling `node-sass`?
The module's description at npmjs.com states that there might be a problem with resolving #!/usr/bin/env node under Ubuntu and how to fix this but that is not the case on my machine.
I could not find anything useful so I hope that you might help me.
I'm using node v0.12.2 under Ubuntu 14.10.
P.S.: I already tried to reinstall node-sass but without success. Nothing changes.
If you're using node 4.x or later then you need to reinstall gulp-sass with:
npm uninstall --save-dev gulp-sass
npm install --save-dev gulp-sass#2
You’ve probably tried to reinstall node-sass while using
npm install node-sass
or
npm uninstall node-sass
npm install node-sass
But node-sass is a C version of Sass. You have to use npm rebuild:
npm rebuild node-sass
I fixed this issue by deleting the existing /node_modules folder and running npm update
This is the only solution that worked for me,
sudo npm install -g n
sudo n 0.12.7
npm install node-sass#2
sudo npm -g install node-gyp#3
npm rebuild node-sass
This workaround (http://forum.ionicframework.com/t/error-running-gulp-sass/32311/20) worked form me.
Starting with this setup:
Cordova CLI: 5.3.3
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.0
Ionic Version: 1.1.0
Ionic CLI Version: 1.6.5
Ionic App Lib Version: 0.3.9
ios-deploy version: Not installed
ios-sim version: 5.0.1
OS: Mac OS X Yosemite
Node Version: v4.1.1
Xcode version: Xcode 6.4 Build version 6E35b
I've found a solution to avoid to use 'sudo' command. We need before to fix npm permissions following this: https://docs.npmjs.com/getting-started/fixing-npm-permissions and fixing permissions for Node here: http://mawaha.com/permission-fix-node-js/ After this we can check and reinstall software without 'sudo' for npm, n or ionic.
I followed this step:
npm install -g n
rm -R node_modules/
npm install node-sass#3.3.3
npm -g install node-gyp#3
npm uninstall gulp-sass
npm install gulp-sass#2
npm rebuild node-sass
ionic setup sass
Why node-sass#3.3.3? Because it works with latest ionic version: https://github.com/driftyco/ionic/pull/4449
Combining the two answers above worked for me, plus additions:
sudo npm uninstall --save gulp-sass
npm install --save gulp-sass#2
npm update
npm rebuild node-sass
I have solved this to create the right directory with the specified binding.node file. You can download the bindings from github
https://github.com/sass/node-sass-binaries
Look in the error message the path where it tries to find the binding. In my case:
C:\Users\Martijn\Documents\node_modules\gulp-sass\node_modules\node-sass\vendor\win32-x64-46
So I create this map win32-x64-46 and copy the binding from github in.
My solution was to downgrade to v0.10.25 (try sudo n 0.10.25 if you use n)
For me, this issue was caused in my build system (Travis CI) by doing something kind of dumb in my .travis.yml file. In effect, I was calling npm install before nvm use 0.12, and this was causing node-sass to be built for 0.10 instead of 0.12. My solution was simply moving nvm use out of the .travis.yml file’s before_script section to before the npm install command, which was in the before_install section.
This was a Node version issue for me, try using nvm to backtrack your version to something like: 0.10.32. This worked for me. I was running 4.2.2
I solved this problem by updating my gcc from 4.4.x to 4.7.x
No need for sudo or re-installations. This has always worked for me:
nvm use 0.12.2
This is the steps I undertook to fix my issue.
I updated my node manually to the latest version
Reinstalled node-sass
npm install node-sass
3.npm audit fix to fix certain vulnerabilities.
`npm audit fix`
5.npm install node-sass
`npm install node-sass`
worked and compiled properly thereafter.
I apologize if anything related to my answer isn't right. I'm just a beginner.
Hope it works for you

How to install `yeoman` latest version?

I installed the node as new version. once i installed i checked in cmd for like this:
C:\Users\Mohamed.Arif>node --version && npm --version
v0.10.35
1.4.28
But after I installed the node, npm I am trying to install the latest yeoman. in their website, i noted the npm version requires v2.1.0+ - i confused here. how to i install the npm as they requested?
I am running the latest version of node only.
Install prerequisites
Before installing Yeoman, you will need the following:
Node.js v0.10.x+
npm (which comes bundled with Node) v2.1.0+
git
You can check if you have Node and npm installed by typing:
http://yeoman.io/codelab/setup.html
What is wrong here? I am working with windows7.
Thanks in advance!
See How do I update npm on Windows?
tl;dr - npm -g install npm does work, but the old version of npm is still in your PATH.
Option 3: navigate to C:\Program Files (x86)\nodejs with cmd.exe and then run
the installation without -g:
npm install npm

npm doesn't work with latest stable node?

I am really new to node/npm, but I upgraded my node (I don't even remember why at this point) when I was trying to install a logging solution (which aren't compatible with 0.10 anyway) and now npm doesn't work I get this:
Error: npm doesn't work with node v0.10.26
I didn't find any question or answer to this. Since I can't use npm at all I can't npm upgrade or npm remove. Node is awesome, but it is very confusing sometimes.
Thanks!
The latest npm version should always work with the latest stable Node.js version. Update npm as well.
For the n version manager, the best solution seems to be to reinstall npm from npmjs.org:
curl -L https://npmjs.org/install.sh | sh

How to use a specific version of NPM?

How can I switch which version of npm I'm using?
Currently:
$ npm -v
1.1.65
But I need: 1.0.x
I tried but got an error:
$npm version 1.0
npm ERR! version No package.json found
Anyone know how to use a different version of NPM? Thanks
Your NPM version is tied to your NodeJS version. As far as I can tell you can only have one NPM version per Node version. Using something like nodenv or, my favorite, asdf, you can define your node version per folder.
Per Node version (e.g. per folder) you globally install the version of NPM that you want to use.
$ npm install -g npm#x.x
Edit: You can also now specify NPM version in your package.json "engines" key, though it takes a little more work to enforce that declaration.
You can update npm without installing another version of node.js and npm is not tied to versions of node.js specifically.
Of course, as node.js advances and adds features so too does npm so there is some limit for npm depending on node.js but you SHOULD update npm as much as you can because there are important security patches and bug fixes.
This is a best practice for all software. Stability is not worth ignoring a security risk.
The command is npm install npm#latest -g to install it globally. This will install the latest version that will run with the node.js you have installed.
Additionally you can install a specific version of npm to your package.json in a project like this npm install npm#6.14 and you can use it locally. What is even more interesting is you can install a local version of node.js in a project and use it too!
Example:
I am running node 16.8.0 and I have npm 7.21.0 but I want to use an earlier version of npm but just for a project:
In the project directory
npm i --save-dev npm#6.14
This will put the earlier version of npm into the node_modules/.bin which will let you run it in relation to this project. If you type npm -v at this point you will get your global version.
If you type node_modules/.bin/npm -v you will get 6.14.15
Since you have made this version of npm the one for this project, when you use npm in your scripts it will use 6.14.15 and not the global version.
The same is true of node.js.
You can install an older version of node.js like this: node_modules/.bin/npm install --save-dev node#lts which will then add this version of node.js to the project.
You can test this by entering node_modules/.bin/node -v and in my example you will see the locally installed version number, in my example v14.17.3 although my global is v16.8.0
If you do this, your project scripts in package.json scripts will run the locally installed versions rather than the global versions.
You can test this out by creating a script in your package.json.scripts like this: "what:version": "npm -v && node -v",
Then if you run npm run what:version you will get
> what:version
> npm -v && node -v
6.14.15
v14.17.3
What value is this?
It is a way for you to package node and npm with your project. This can be especially valuable for large projects where you have many people working on the same project, so you have consistency across the board or if you have a build server that has a specific version of node + npm. Additionally if you have corporate requirements, etc.
Additionally there is npx which allows you to do so much more. Using npx you can even try something out without installing it.
Here is the documentation for npm: https://docs.npmjs.com/about-npm-versions
If you find you are needing to switch between different versions of node.js and npm you might want to use nvm https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
When you install npm you only get the latest package, so you need to install specific versions individually, e.g:
npm install -g npm#5.6.0
Once you've done that, run a version check and you should see the version you've just installed:
npm -v
5.6.0
You can install specific version by bellow command.
npm install -g npm#6.14.11
For a specific version, use
npm install -g npm#x.y.z
And for the latest version, use
npm install -g npm#latest

Resources