Previously, I had node version v0.10.46 installed on my ec2 server. For a recent project, I decided to give pm2 a try and installed pm2 using
npm install pm2 -g.
But, pm2 start index.js errored out since the project was using some ES6 syntax with arrow functions and let keyword.
Therefore, I updated the node version using nvm to latest v6.9.1, which is also the same version which we used for developing on local (windows).
However, pm2 start index.js again errored out with the same error:
pm2 show index hinted that the nodejs version was still not updated. I removed the old nodejs version, installed pm2 again, still of no avail.
I tried with other methods as well, by using:
pm2 start index.js --interpreter=~/.nvm/versions/node/v6.9.1/bin/node
to force pm2 to use the latest installed version of node. Every single try gave me the same errors with the same version of nodejs. Why is Pm2 not taking the latest version of node and sticking with 0.10.46?
If it helps:
which node
~/.nvm/versions/node/v6.9.1/bin/node
which pm2
~/.nvm/versions/node/v6.9.1/bin/pm2
Also, v0.10.46 was NOT installed using nvm.
Edit:
Here are the running pm2 daemons, using ps -ef | grep pm2:
Note that ec2-user is the logged in user and I also tried the same with root user. I installed nvm running node v6.9.1 and pm2 as root user as well with no success. I get the same error.
NVM allows you to run multiple version of node at a single time (between multiple shells). This means that when you run nvm use you are using that version of node within the context of that running shell.
Given PM2 runs as a daemon, I believe it kicks off its own process which is why it is not using the current nvm selected version.
This GitHub issue shows the usage of the interpreter flag which might be helpful for your specific issue https://github.com/Unitech/pm2/issues/1034
If the actual issue here is with the PM2 process needing to be running a specific NodeJS version, instead of an application PM2 is spawning, restarting the PM2 dameon itself after running the nvm use would have it startup with the current version of Node selected by nvm.
Related
Hello I am currently stuck with a task that is given to me. The problem is that I am unable to install dependencies when running npm install which means that I am unable to run the website locally which is my main goal
There are many versions of this question in the internet but I am not really sure what the main cause of this therefore the title of this question
you can view my error logs here
https://www.codepile.net/pile/4qL4NOq0
I have also tried some solutions that I have seen on the internet such as:
reinstalling node
deleting node_modules and package-lock.json and re-npm install (this is when I have installed the node_modules but still unable to run the website locally)
installing grpc globally
The version of grpc that you are installing (1.23.3) does not support the version of Node.js that you are using (16). You will need to use a newer version of grpc (the latest is 1.24.11) or an older version of Node to get that to work.
Please note that the grpc package has been deprecated in favor of the #grpc/grpc-js package. It is recommended that you use that one instead if possible.
I tried to upgrade my Node version, I downloaded the file from their website, run through the installation and everything seemed OK.
When I tried to check if the latest version has been installed, node -v showed me v7.7.4 instead of v8.4.0.
I tried brew upgrade node but it told me node 8.4.0 is already installed.
How do I switch to the latest version?
Thanks!
You're using nvm to install multiple versions of Node.js, and it looks like you set 7.7.4 as the default version of Node that nvm should use, which means that even though the system-wide version of Node is 8.4.0, nvm will insert the path to the 7.7.4 executable earlier in $PATH.
You can change the default to point to the system-wide version:
nvm alias default system
FWIW, Homebrew (brew) is yet another method of installing Node. However, given the amount of issues I see being posted here on StackOverflow related to that particular install, I wouldn't advise using it. Use the official installer to install the system-wide Node, and use nvm to manage different versions (for instance, to test your code with).
you can check your installation directory
Command : 'where node '
I installed node via NVM. I installed node 0.10.32. using NVM 0.25.0
When I do node -v I get
-bash: /root/.nvm/v0.10.32/bin/node: No such file or directory
when I do npm v I get
/root/.nvm/v0.10.32/bin/npm: 2: exec: /root/.nvm/v0.10.32/bin/node: not found
All those directories exist and node executable is in it but they are reading as not found. Node seems to be installed but I am unable to use it. I am not sure how to fix this issue. Any ideas will be greatly appreciated
Check that your ~/.bash_profile has this:
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
https://github.com/creationix/nvm/issues/576
A lot of things can be wrong here from what you describe. Generally I don't recommend using nvm to install Node on servers. It works fine for your own work on a local machine but when you need to be sure what is installed and where, I recommend doing a real installation.
I recently wrote a tutorial on how to install Node on Linux:
https://gist.github.com/rsp/edf756a05b10f25ee305cc98a161876a
It is specifically about version 6.7.0 but just change the version number to use any other version of Node.
You can see other answers showing how to install Node properly and troubleshoot if it isn't installed correctly:
Run npm as superuser, it isn't a good idea?
node 5.5.0 already installed but node -v fetches with "v4.2.1" on OS X & homebrew?
Just get the binary or source package of the version that you need, install it where you want and it will work. The most reliable way is to install a source package because you can run make test before you install and because npm will have the correct shebang line (which may not always be the case with binary distribution - which, incidentally, is also used by nvm). No need to use nvm or any other tool to do that.
The nvm is great if you need to quickly switch Node versions during development on your local machine but if you want a reliable way to install Node on the server then it's best to install it normally.
Server: Ubuntu server 14.04
Node: v4.2.6 LTS
npm: 1.3.10
I pullled my colleage's work from git remote. He made the node_modules as .gitignore. So I have to npm install the modules.
But after a successful install of npm. when I try to start the project using mocha. It remind me of a module didn't self-register
The error comes from the module of Bcrypt.
at bindings (/base_dir/node_modules/bcrypt/node_modules/bindings/bindings.js:76:44)
I don't want to downgrade my node to 0.10, because, I can't use JS promise in that version. Somehow, JS promise is a must in my work
This problem happens mostly because you copied/cloned the repository from somewhere else, but some modules for nodeJS should be installed/registered locally on your machine, during which the happens the build process(maybe some native language like C).
and be noted that the node_modules folder should not be staged for versioning. and should be ignored by versioning tool. and the one who is trying to clone this package should build / install firstly.
I find the answer to this problem.
But plz don't devoted this just because you want.
I upgrade the NPM using
npm install npm -g.
after that, delete the node_modules folder,
then,
npm install
Everything will be good.
I had this issue while setting up my Cypress project.
After trying to delete and then reinstalling all the node-modules and upgrading everything I found out the issue was caused because Cypress uses node from its bundle version by default (which was version 8.0 in my case) , whilst the package I wanted to use required the node version to be 10 or higher.
I did have node 12.0 installed on my machine but since cypress was not using that I had to add the line shown below in the settings file (cypress.json) to set the value for 'nodeVersion' to 'system', this way you are telling cypress explicitly to use the node version installed on your machine.
Add this line to your settings file:
**"nodeVersion": "system"**
I recently got an email from MongoDB to update my drivers to be compatible with the new MongoDB 3.0
I am trying to up my Node.js to version "1.4.29". Currently I am the running the node version "0.10.35".
How can I upgrade node.js driver via NPM to 1.4.29 to be compatible with MongoDB 3.0?
I have tried the following:
npm install g -n
I also tried this:
It just won't install any version higher then 0.10.35, Its stuck at the version. In the image above you can see it starts of my install node version 4.0 but ends up with 0.10.35 which I already have.
Which I was told would get the latest version of node but that did not seem to work.
Thanks in advance.
First you need to clean the cache and then start the up gradation process. Use the below commands in the NodeJS command window to upgrade to latest version.
npm cache clean
npm update -g
If you desire to install specific version of node then use the command sudo n 0.12.2
Reference taken from How to upgrade Node.js via NPM
The way to install the new versions of node with n is to use this command n <version>. For example use n 5.1.0 for the latest version of nodejs.