Cannot find module 'npmlog' error message when using npm command - javascript

Today is my first day of my first job and after setting up my development environment by updating node and npm on my Mac (OSX) I seem to have broken something. Every time I try to use npm in my commandline (npm init, npm install, etc.) I get this error message:
module.js:339
throw err;
Error: Cannot find module 'npmlog'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:20:13
at Object. (/usr/local/lib/node_modules/npm/bin/npm->cli.js:76:3)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
There isn't much of an error message to go off and the stack trace isn't helping me all that much either. Here's what I have tried:
Searched around Stackoverflow and though there are similar problems, people have been able to use npm <something> to solve their problem, which I cannot do.
Uninstalling and reinstalling npm - Didn't work because I can't use npm command at all so things like sudo npm uninstall npm -g don't work.
Removed npmlog directory from .npm directory and then cloned the github repo directly to the directory again.
Hopefully one of you have run into this before or have an idea of how to approach it. Any help is appreciated.

Here is one good link Fixing npm On Mac OS X for Homebrew Users.
with following commands when try to upgrade node.js under mac
rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node --without-npm
echo prefix=~/.npm-packages >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sudo sh

Here are the steps that worked for me:
$ sudo rm -rf /usr/local/bin/npm
$ sudo rm -rf /usr/local/lib/node_modules/npm
$ brew uninstall node
$ brew install node

Try curl -0 -L http://npmjs.org/install.sh | sudo sh to follow redirects. Also notice I added sudo before the sudo sh command depending on your users permissions.

I've just encountered this issue on a Mac, and on closer inspection it seems to me that the problem is that inside the Node application directory in certain circumstances the link in the node/bin directory to npm in lib/node_modules/npm/bin is replaced by the file itself and that is why it fails (and why all the various script methods fix it, because they correctly retain the file link).
If I copy the contents from node-v6.9.4-darwin-x64 with cp then I get this problem, but if I copy the files using the Finder, then I don't. So, you can fix it by manually recreating the link with ln if you don't want to use the Finder (alternatively, mv or rsync -a could work too; I haven't tested them).
Hope this helps someone coming here for this problem.
Edit: I've just accidentally found the reason for the problem on Macs (for my particular scenario, at any rate): I've always used cp -r to copy directories. This is because I am old, and don't learn new things any more. The correct way is cp -R, which correctly copies everything, as it should.

I didn't necessarily "fix" the problem as much as just start over. I used this post to do so: How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
If anyone else knows how to actually fix the problem or knows what I did to cause it I would still be very interested.

in my condition, I just
brew uninstall node
and download from the official site and worked for me

I hit this on Fedora 27 after I ran sudo npm install npm -g.
The problem was that I had initially installed Node.js via sudo dnf install nodejs which installs npm into /usr/local/bin and /usr/local/lib. However running sudo npm install installs a separate version in /usr/bin/
Running which npm shows up that the extra npm is installed. Then the following cleaned everything for me:
$ sudo rm /usr/bin/npm
$ sudo rm -rf /usr/lib/node_modules/npm
$ dnf remove -y nodejs
$ dnf install -y nodejs

I encountered this same error. This was on a server not connected to the internet. I had seen a thread on Github that mentioned sometimes symbolic links can be removed while performing copies or other file operations. So I did a "find" on the node directory for symbolic links of the problematic server and none where found. Doing the same on a working server found symbolic link files.
I went to NODE_HOME/bin and did an ls -l
Sure enough I had a file for npm. Performed the same steps on a working server and the npm file was a symbolic link. To fix the problematic server, I performed the following:
rm npm
ln -s ../lib/node_modules/npm/bin/npm-cli.js npm

Got the same error while installing protractor in REDHAT linux updated the
npm
file at
/node-v6.10.2-linux-x64/bin/npm
for the module path as below:
Code Before
var log = require('npmlog')
Code After
var log = require('/node-v6.10.2-linux-x64/lib/node_modules/npm/node_modules/npmlog')

For me, I ran brew uninstall node and then download the latest version from nodejs.org and it worked.

Related

Error while installing react app. an error occured while installing react app [duplicate]

I'm trying to run npm install, this is output from console:
npm ERR! Linux 4.8.0-27-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! Maximum call stack size exceeded
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
and this is content of npm-debug.log:
113791 verbose stack RangeError: Maximum call stack size exceeded
113791 verbose stack at Object.color (/usr/lib/node_modules/npm/node_modules/npmlog/node_modules/console-control-strings/index.js:115:32)
113791 verbose stack at EventEmitter.log._format (/usr/lib/node_modules/npm/node_modules/npmlog/log.js:252:51)
113791 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npmlog/log.js:138:24)
113791 verbose stack at emitThree (events.js:116:13)
113791 verbose stack at emit (events.js:194:7)
113791 verbose stack at .<anonymous> (/usr/lib/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js:23:18)
113791 verbose stack at emitThree (events.js:116:13)
113791 verbose stack at emit (events.js:194:7)
113791 verbose stack at .<anonymous> (/usr/lib/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js:23:18)
113791 verbose stack at emitThree (events.js:116:13)
113791 verbose stack at emit (events.js:194:7)
113792 verbose cwd /home/giorgi/AdMove/dev/web-advertiser-admove
113793 error Linux 4.8.0-27-generic
113794 error argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
113795 error node v6.9.1
113796 error npm v3.10.8
113797 error Maximum call stack size exceeded
113798 error If you need help, you may report this error at:
113798 error <https://github.com/npm/npm/issues>
113799 verbose exit [ 1, true ]
Removed node_modules several times and tried to reinstall. Can't understand what's the reason that causes this and how to fix it.
metzelder's answer helped me fix the issue. however if you run the command npm cache clean, it will give you a message
As of npm#5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid
So, as of npm5 you can do by adding a --force flag to the command.
So the command is:
npm cache clean --force
npm rebuild
it has solved my problem
Try removing package-lock.json and the node_modules folder:
rm package-lock.json
rm -r node_modules
I had the same issue with npm install.
After a lot of search, I found out that removing your .npmrc file or its content (found at %USERPROFILE%/.npmrc), will solve this issue. This worked for me.
npm uninstall
npm cache clean --force
I tried these two methods but they didn't work. After, I deleted the node_modules directory and ran npm install again, it still didn't work. Lastly, I deleted package-lock.json and created a new package-lock.json file using
npm install
I have overcome this issue by doing following:
Delete all the content of the npm dependencies. You can find the default install location according to this thread:
https://stackoverflow.com/a/5926706/1850297
Before you run npm install command, I suggest to run npm cache clean --force
npm rebuild will work for sure
In my case, update to the newest version:
npm install -g npm
I deleted
node_modules
and then reinstalled by
npm install
It worked for me
I have also faced the same problem and this is how i resolved it.
First of all you need to make sure that your node and npm versions are up to date. if not please upgrade your node and npm packages to latest versions.
nvm install 12.18.3 // update node version through node version manager
npm install npm // update your npm version to latest
Delete your node_modules folder and package-lock.json file.
Force clean the entire NPM cache by using following comand.
npm cache clean --force
Re-Install all the dependencies.
npm install
If above step didn't resolve your problem, try to re-install your dependencies after executing following command.
npm rebuild
This issue can also happen if you're trying to install a package that doesn't exist or if you're trying to install a version that doesn't exist.
npm cache clean returns below message
As of npm#5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead. On the other hand, if you're debugging an issue with the installer, you can use npm install --cache /tmp/empty-cache to use a temporary cache instead of nuking the actual one.
If you run npm cache verify, as specified above, then it actually runs cache verification and garbage collection which fixes the problem.
Cache verified and compressed (~\AppData\Roaming\npm-cache_cacache):
Content verified: 6183 (447214684 bytes) Content garbage-collected: 16
(653745 bytes) Index entries: 9633
Happened in docker (node:15-buster) for me.
Remember to use WORKDIR /<folder> so that it doesn't conflict with original npm libraries installed.
The folder can be anything but system folders, so that includes using /.
In case none of these answer work for you, it may be because the terminal you're using isn't the right one/ your node_modules is used by another part of your computer.
In my case I kept juggling between this error (maximum call stack size exceeded) and the access error event when I did a sudo npm i.
The fix was to close my IDE (which was WebStorm), run npm i in a basic terminal, and that was it.
I'm not a Windows user, so if you are, try to check Rene Knop comment.
For Unix/OSX users, I've removed the root .npmrc file ~/.npmrc.
Before you're going to try it, please,
check if there is nothing necessary over there
you can use this command to bring all content into your terminal: cat ~/.npmrc .
If you have got something like:
cat: /Users/$USER/.npmrc: No such file or directory
to save a copy:
cp ~/.npmrc ~/.npmrc_copy
Now, try to remove it (Works for bash users: Unix / Ubuntu / OSX ...):
rm -f ~/.npmrc
This worked for me.
Hope this will be helpful for others.
I also had the same problem. I had tried the previous solutions, but the solution for me was much simpler. I only had to remove the space in the directory and then run npm i again
Thanks to: https://github.com/nodejs/node-gyp/issues/809#issuecomment-155019383 for pointing this out.
In my case I had a custom .npmrc file that included an auth token for authenticating with a private npm registry.
The token had expired, which helpfully returned code E401: Incorrect or missing password locally, but ERR! Maximum call stack size exceeded from the CI build.
You uninstall npm package and force clean the cache and close terminal and reinstall whichever package be.
$sudo npm uninstall <package - name>
$sudo npm cache clean --force
Then restart terminal and check
Still not working upgrade both npm and node to the latest version
Today we encountered this error when running an npm prune even after running an npm cache clean --force.
Versions:
node 13.8.0
npm 6.13.6
Deleting the package-lock.json worked for this case as well. Thank you all!
In general, once a module has been installed, it's much more convenient to use npm ci instead of npm install. Please check out this SO answer for the advantages of the former with respect to the later in a production environment.
So please just run
npm ci
All dependencies will be updated, and the problem will disappear. Or it will error in the case there's some grave de-synchronization between one and the other.
Most of the times, this issue occurs if you are using the system provided by the organization you work for and it's vpn restricts the use of this command.
In this case, you may try to disconnect from organization vpn and then execute this command.
I tried everything to fix this issue on my Mac. I think the issue started when I had already downloaded npm from Node.js and then reinstalled it with Homebrew while following along with a Team Treehouse video.
Here's what I tried:
From https://docs.npmjs.com/misc/removing-npm
sudo npm uninstall npm -g
sudo make uninstall
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*
From How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
Here's what worked:
In the end, the only thing that worked for me was to clone down the npm-reinstall repo from GitHub that completely removed everything related to npm on my Mac.
https://github.com/brock/node-reinstall
I then had to reinstall node and npm from Node.js.
I tried everything to fix this issue on my windows 7 machine like
Reinstalling and rebuilding npm
At last, I fixed this small configuration setting issue by wasting my entire day.
How I resolved this issue
Removing my project specific configurations in global .npmrc
at location like drive:/Windows/Users/../.npmrc
I solved it 100% I had this problem with gulp version: 3.5.6.
You should clean the package-lock.js and then run npm install and It worked form
Our company dev environment uses Artifactory as the default registry for our NPM dependencies, and when running npm install it was defaulting to this, which did not work... so manually specifying the main npm registry via npm install --registry https://registry.npmjs.org fixed this issue for me...
I was facing the same error, I was trying to install jest into to one of the packages in a monorepo project.
If you are using Yarn + Learna to package a monorepo project, you will have to navigate to the package.json inside the target package and then run npm install or npm install <package name>.
I don't know why, but I ran npm install with sudo and it worked.
sudo npm install
I had this problem and it was due to an upgrade of my git executable. I rolled back to Git-2.21.0.rc1.windows.1-64-bit and added this to my environment path and it fixed my issue.
The one thing that finally worked for me on Mac was upgrading from node 8.12 to 10.x using NVM.
I uninstalled all other versions of Node with NVM, then installed 10.x, then ran nvm alias default node, which tells NVM to always default to the latest available node version on a shell.
After that, my live reloading issue went away!
Switching to yarn solved the issue for me.

yarn command not found after installing via npm

As per the yarn installation for yarn v2, they want you to install using npm install -g yarn. So I ran sudo npm install -g yarn on Ubuntu 20.04. But after I do that, it says command not found.
❯ sudo npm install -g yarn
> yarn#1.22.10 preinstall /usr/local/lib/node_modules/yarn
> :; (node ./preinstall.js > /dev/null 2>&1 || true)
❯ yarn --version
zsh: command not found: yarn
sudo npm install -g npm
then
sudo npm install -g yarn
Then reboot your system. That did it for me.
Before a reboot only sudo yarn worked. I tried looking at file permissions but everything seemed in order and the files were executable as expected. Nevertheless after a reboot it worked.
If you go to /usr/local/bin after the installation there's a link there to where yarn.js lives, as expected, and file permissions for it were also correct.
/usr/local/bin is added to $PATH, so it's surprising that it doesn't see the new cmd right away, but perhaps it didn't reload or map it until after the reboot? I don't know. But I just spent a good hour trying to figure this out so I'm posting what worked for me to spare other the hassle.
TL;DR
If you are managing node via nvm, then probably the path to yarn binary is not included in the $PATH variable. You should add this -
# Add this at the end (or after the $NVM_DIR initialization)
# in your profile - .bashrc | .zshrc | .profile, etc
export PATH="`yarn global bin`:$PATH"
at the end of your profile file (.zshrc for me) or at least after the $NVM_DIR initialization.
I have recently faced this issue and while searching for a solution, I landed up here.
Here is what my environment looks like:
OS: Ubuntu 20.04
Shell: zsh
NodeJS: managing it via nvm, and NOT apt.
After going through all the answers, I was not keen on uninstalling anything. So I tried to dig a bit deeper.
I installed yarn via npm install -g yarn command. So the first thing I wanted to verify was the location of the yarn binary. To do this, I ran the command where yarn which lists the installation path for the yarn binary.
$ where yarn
/home/<user_name>/.nvm/versions/node/v16.11.1/bin/yarn
Then it hit me. In my .zshrc file, I had added the yarn global bin command (which spills out the directory of all the global packages installed by yarn) at the top like so:
# Top of my .zshrc file
export PATH="`yarn global bin`:$HOME/bin:/usr/local/bin:$PATH"
and as per the installation instruction of nvm, the $NVM_DIR (the variable which holds the nvm directory path) was added at the end of my .zshrc file.
So when I was starting up my shell, it was actually trying to load the yarn command (present inside the nvm directory) even before loading the $NVM_DIR path.
To solve this, I tweaked my .zshrc file and moved the yarn global bin command after the $NVM_DIR like this:
# Top of my .zshrc file
export PATH="$HOME/bin:/usr/local/bin:$PATH"
# ...
#
# Something in between
#
# ...
# Bottom of my .zshrc file
export NVM_DIR="${HOME}/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# Here is where I have added the path to yarn global
export PATH="`yarn global bin`:$$PATH"
I hope that this would be of help.
This solved it for me:
corepack enable
(if you get "Internal Error: EACCES: permission denied", run it with sudo)
This is also recommended by the Yarn documentation: https://yarnpkg.com/getting-started/install
Uninstall cmdtest:
sudo apt remove cmdtest
Then, run these commands:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install yarn
If you want to avoid reboot, use
/usr/local/lib/node_modules/yarn/bin/yarn --version
The yarn documentation is missing a step, you need to restart your computer between this installation and running yarn --version.
This worked for me
I recently had a similar situation and here is how I solved it.
First I troubleshoot the current npm installation:
npm config -list
I had a ~/.npmrc file that had a different prefix:
PREFIX=/opt/homebrew
That made my npm installation look for globally installed packages under /opt/homebrew.
In my case, I'm using a different npm installation (not with homebrew anymore). A simple fix is to remove this custom PREFIX from the ~/.npmrc file and the problem was solved.
Now npm looks for globally installed packages under /usr/local/bin/.
I installed yarn with npm install -g yarn on git bash and I tested it with yarn -v that show the version of the installed yarn, but when I used yarn start it gives me this error
C:\Users\{username}\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found
These are simple steps that I used to fix my problem on Windows 10:
Uninstall node.js
Restart your computer
Delete your C:\Program Files\nodejs and C:\Users\{username}\AppData\Roaming\npm
Install node.js again and check it with node -v
Start your vs code as an admin and write npm install
Write yarn start

Expo commands throwing "Error: Cannot find module 'minizlib'"

Whenever I try to run such commands as expo init or expo start or even just expo, it responds with:
Error: Cannot find module 'minizlib'
Require stack:
- /usr/local/lib/node_modules/expo-cli/node_modules/tar/lib/pack.js
- /usr/local/lib/node_modules/expo-cli/node_modules/tar/lib/create.js
- /usr/local/lib/node_modules/expo-cli/node_modules/tar/index.js
- /usr/local/lib/node_modules/expo-cli/node_modules/#expo/xdl/build/Extract.js
- /usr/local/lib/node_modules/expo-cli/node_modules/#expo/xdl/build/Api.js
- /usr/local/lib/node_modules/expo-cli/node_modules/#expo/xdl/build/xdl.js
- /usr/local/lib/node_modules/expo-cli/build/exp.js
- /usr/local/lib/node_modules/expo-cli/bin/expo.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
at Function.Module._load (internal/modules/cjs/loader.js:527:27)
at Module.require (internal/modules/cjs/loader.js:683:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (/usr/local/lib/node_modules/expo-cli/node_modules/tar/lib/pack.js:28:14)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:683:19)
I have tried install and reinstalling minizlib, along with expo, expo-cli, npm, and node and nothing has worked.
Any help would be appreciated.
OS: Ubuntu 18.04.2
I had the same issue. I downgraded to version 10 of node using nvm install 10 (If you do not have NVM look into it here it is very useful) then reinstalled the expo-cli with npm install -g expo-cli. This ended up solving the issue for me.
Note: This downgrade is temporary if you want to make it your default version you have to run nvm alias default 10
I had the same issue with "minizlib" not being found. None of the solutions posted on here or other threads regarding this issue solved it.
But, I figured it out. And here is what worked for me. Its pretty straight forward.
All the modules necessary for Expo to run should be located at
/usr/local/lib/node_modules/expo-cli/node_modules/
So, go to your home directory and run npm install minizlib#2.1.0.
This will put the module file in the home directory. (I say home
directory so that the npm install doesnt clutter files into whichever
directory you were previously working on)
Now, you need to copy+paste the module folder to whichever folder npm
is looking for while running the expo command. In your case its
/usr/local/lib/node_modules/expo-cli/node_modules/
This solved the problem for me. If it worked for anyone else, please validate it for me.
install the library
npm install -g minizlib
I had the same issue and I found the way to solve it in an external forum. thanks to #parkerroanm answer there.
Anyway, here is how I solved it (from the answer I found):
I uninstalled expo-cli with this command: sudo npm uninstall -g expo-cli This is did not actually uninstall expo and nothing I could do would. So i deleted the folder with this command: sudo rm -r /usr/local/lib/node_modules/expo-cli
Then reinstalled using yarn instead with: yarn global add expo-cli --save
I updated the PATH in .bashrc to include export PATH="$(yarn global bin):$PATH" to the bottom of the file.
This fixed the issue for me.
It seems to all stem from a permissions error on installation for the
sharp library.

I tried to install NPM and ng and none of the commands work. I need to remove everything and start over

I am new to Angular and terminal use. I installed NPM and was trying to use ng serve and that is where the problems began. I am ready to completely uninstall everything and start over.
I have researched and tried uninstalling and reinstalling. I have cleared the cache. I tried adding to the bash_profile file and the .bashrc based on what other answers said to do but I think that made things worse. Every command I run says -bash: /usr/local/bin/npm: No such file or directory and nothing will work.
I tried following other uninstall tutorials but I just get more errors.
npm help
bash: /usr/local/bin/npm: No such file or directory
npm deactivate
bash: /usr/local/bin/npm: No such file or directory
Install new version of Node.js and NPM from here https://nodejs.org/en/download/:
sudo apt install nodejs npm
There might be installation issue. If you try more, I believe you can do. You can also take help from here https://www.w3schools.com/nodejs/

browserify error /usr/bin/env: node: No such file or directory

I installed node js and npm via apt-get install and all of the dependencies, then I installed browserify
npm install browserify -g
it goes through the process and it seems like it installed correctly, but when I try to do a simple bundle per this walkthrough
I get the error:
/usr/bin/env: node: No such file or directory
Some linux distributions install nodejs not as "node" executable but as "nodejs".
In this case you have to manually link to "node" as many packages are programmed after the "node" binary. Something similar also occurs with "python2" not linked to "python".
In this case you can do an easy symlink. For linux distributions which install package binaries to /usr/bin you can do
ln -s /usr/bin/nodejs /usr/bin/node
New Answer:
Uninstall any nodejs package you've installed via your system package manager (dnf, apt-get, etc), delete any silly symlinks you've been recreating every upgrade (lol).
Install NVM,
use nvm to install nodejs: nvm install 6
Old Answer:
Any talk of creating symlinks or installing some other node-package are spurious and not sustainable.
The correct way to solve this is to :
simple install the nodejs package with apt-get like you already have
use update-alternatives to indicate your nodejs binary is responsible for #!/usr/bin/env node
Like so :
sudo apt-get install nodejs
sudo update-alternatives --install /usr/bin/node nodejs /usr/bin/nodejs 100
This now becomes sustainable throughout package upgrades, dist-upgrades and so forth.
Run apt-get install nodejs-legacy.
Certain linux distributions have changed node.js binary name making it uncompatible with a lot of node.js packages. Package nodejs-legacy provides a symlink to resolve this.
You can also install Nodejs using NVM or Nodejs Version Manager. There are a lot of benefits to using a version manager. One of them being you don't have to worry about this issue.
Instructions:
sudo apt-get update
sudo apt-get install build-essential libssl-dev
Once the prerequisite packages are installed, you can pull down the nvm installation script from the project's GitHub page. The version number may be different, but in general, you can download and install it with the following syntax:
curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh
This will download the script and run it. It will install the software into a subdirectory of your home directory at ~/.nvm. It will also add the necessary lines to your ~/.profile file to use the file.
To gain access to the nvm functionality, you'll need to log out and log back in again, or you can source the ~/.profile file so that your current session knows about the changes:
source ~/.profile
Now that you have nvm installed, you can install isolated Node.js versions.
To find out the versions of Node.js that are available for installation, you can type:
nvm ls-remote
. . .
v0.11.10
v0.11.11
v0.11.12
v0.11.13
v0.11.14
As you can see, the newest version at the time of this writing is v0.11.14. You can install that by typing:
nvm install 0.11.14
Usually, nvm will switch to use the most recently installed version. You can explicitly tell nvm to use the version we just downloaded by typing:
nvm use 0.11.14
When you install Node.js using nvm, the executable is called node. You can see the version currently being used by the shell by typing:
node -v
The comeplete tutorial can be found here
sudo apt-get install nodejs-legacy
This creates the symlink /usr/bin/node -> nodejs.
Source: https://lists.debian.org/debian-devel-announce/2012/07/msg00002.html
I seem the same problem when I build atom in Linux.
sudo apt-get install nodejs-dev
Fix my question.hope helpful to you.
If you don't want to symlink you could do this.
works in ubuntu
#!/usr/local/bin/node --harmony
harmony tag is for the new ECMAscript harmony
run the command which node the result will be something
/home/moh/.nvm/versions/node/v8.9.4/bin/node
Copy the path that you have got above then run the command in step 3.
ln -s /home/moh/.nvm/versions/node/v8.9.4/bin/node /usr/bin/node
You have to call "nodejs" and not "node". To verify this, type node -v on the shell: if nothing is found try nodejs -v. If that displays a version number, then the command you should be using is nodejs and not node. Therefore, you have to change the call to browserify in your script from node to nodejs (as shown below): replace
#!/usr/bin/env node
with
#!/usr/bin/env nodejs
You might also have to open the script as the superuser.

Categories