I am trying to run my React project by npm start but get following error.
nodenv: version `8.9.1' is not installed
(set by /Users/xyz/github-repos/react/.node-version)
A oneliner solution might be:
nodenv install $(cat .node-version)
print the version specified in .node-version
use that as input for the nodenv install command
If your environment is setup correctly, there is no need to redefine the local version with nodenv local. The version is already saved in the aforementioned .node-version file.
You would run nodenv local <version> on the first system where you define the project's nodejs version to write the preferred nodejs version to .node-version.
Running yarn or yarn install is not part of the requirements to run the correct nodejs version in the project's directory. Running yarn will install the dependencies specified in package.json.
on mac I had to first do
brew upgrade nodenv node-build
then I could do
nodenv install 8.9.1
nodenv local 8.9.1
Following commands fixed my problem
nodenv install 8.9.1
nodenv local 8.9.1
yarn install
Related
I am currently trying to do this:
https://github.com/workshopper/javascripting#run-the-workshop
When I type javascripting it gives me the error:
EEXIST: file already exists, mkdir '/home/vagrant/.config/workshopper'
From what I've found the EEXIST errors comes from the node version not being updated.
The terminal on my mac shows:
% node -v
v12.18.3
% npm -v
6.14.6
But the terminal inside my Vagrant VM shows:
% node -v
v8.9.4
% npm -v
5.6.0
I am assuming it is because /usr/local/bin is not in my $PATH but I'm not sure how to update that, or even if that is the problem. Been struggling with this for a while and haven't found anything online that fixes it.
How do I update node and npm inside the VM?
Thanks.
[Edit]
Just in the odd case someone has this problem in the future, here is how I managed to fix it.
Inside of the VM run:
nvm ls
check to make sure the default is the latest version (in my case it should have been v12.18.3). If it is not the latest, then use:
nvm alias default (latest version number)
If you don't restart your VM then it may not update the current version. In that case use:
nvm use (latest version number)
And then you should be good to go.
Hope this helps!
For me, it was because the node version on my computer was newer than the node version in vagrant. I updated node in vagrant and it worked.
nvm install <version>
nvm use <version>
on a Windows 10 machine and using nvm4w I tried:
from the above image:
node --version to check the current version
nvm list to list installed versions
nvm use 8.8.1 so we switch from 6 to 8
nvm on to enable it
node --version to re-check the node version
what am I doing wrong?
I had to delete the folder located at C:\Program Files\nodejs:
And then run nvm use {version} again to repopulate this folder with the correct node version.
I suspect that nvm is having trouble deleting this folder due to permission issues.
So I found a workaround.
I renamed C:\Program Files\nodejs to C:\Program Files\nodejsx
and then running nvm use versionNumber works fine.
Seems like nvm cannot change it to a symlink and fails silently.
I was also facing the same issue.
I had node version 14.15.1 installed in my machine and had to use 12.16.1
I'm using Windows 10.
After installing 12.16.1 via nvm it was showing only this version in nvm list and it wasn't showing current version in use.
Even after node use 12.16.1 the node -v was still showing 14.15.1.
Steps to resolve this issue:
Uninstall Nodejs from control panel.
Install Nodejs 12.16.1 using nvm install 12.16.1
Install Nodejs 14.15.1 using nvm install 14.15.1 (or the version which got uninstalled)
Switch version using nvm use 12.16.1 (change the version number accordingly)
Result:
C:\>nvm list
14.15.1
* 12.16.1 (Currently using 64-bit executable)
12.3.1
C:\>node -v
v12.16.1
nvm works based on the fundamental idea of symlinks. When a user is trying to hit the command nvm install <node_version> the entered version of node is getting installed even if you have changed the C:\Program Files\nodejs to C:\Program Files\nodejsx.
If nvm fails to create the new folder C:\Program Files\nodejs it will fail silently and you won't be informed.
You must manually check for the existence of the path C:\Program Files\nodejs if it exits then delete the folder and change the node path in your environmental variables. This will help you to figure out the version of the npm command.
Your problem can be solved by reinstalling the nvm version with Administrator privileges or just by renaming the folder C:\Program Files\nodejs
You can find further information here: https://github.com/coreybutler/nvm-windows/issues/67
This happens to be the issue till date and deleting nodejs folder does not work.
Just run nvm install using cmd as administrator.
So even if you have downloaded nodejs from cmd without admin privilages, uninstall it and install again using cmd as admin.
This is what worked for me after trying almost every solution from github and stackoverflow.
For me the problem (on Linux) was that I had installed node with Homebrew, and it was preventing the use of nvm. Before nvm could set up the correct symlink, I had to
brew uninstall node
I first found out about this situation by running
which node
This told me that node was being symlinked from Homebrew at
/home/linuxbrew/.linuxbrew/bin/node
instead of, as we want, from nvm at
/home/john/.nvm/versions...
As soon as "which node" reported that it was using the node from nvm, things were resolved for me.
1) Install NVM from the link : https://github.com/coreybutler/nvm-windows/releases.
2) Copy the settings.txt from the "C:\Users\YOUR_USERNAME\AppData\Roaming\nvm". to "C:\Users\ YOUR_USERNAME"
3) Restart your system for the changes to reflect.
4) Open the console and type below command :
nvm list
5) To install the 6.9.3 version run the below command :
nvm install 6.9.3
6) After the installation is complete it will add the node version in the nvm. To check the same type command :
nvm list
7) To switch the command version type command below command :
nvm use 6.9.3
To verify the node version switch type the command “node –v”
8) Its will display the node version in use.
For more details please check the below link :
https://www.tutespace.com/2018/11/nvm-installation-on-windows.html
Let us know if you still face the same issue.
I had the same problem.
My solution is that i uninstalled nodejs via chocolatey (the way i installed it) and then nvm worked again.
After checking the nodejs folder in C:/Program Files i noticed that nvm probably works via creating a link/shortcut to the nvm folder where the different versions of nodejs are stored. That´s the way the "Path" and everything works.
I hope that helped.
I have tried to switch Node version using nvm but it is not reflecting so I deleted the folder inside c:/program files/nodejs
after deleting the folder follow the same steps to switch the npm version using nvm and it will switch the node version.
The steps I had to follow were:
Uninstall node if there was an installation outside of nvm
Ensure "C:\Program Files\nodejs" was deleted before installing nvm
Install nvm which still fails to install node but from the errors it seems that's because its ultimately pointing at urls that have been decomissioned
Use "nvm install NODE_VERSION" to install at least 2 versions of node which again fail as in 3)
Download the versions of node I tried to install and unzip the entire contents to their respective %appdata%/nvm/vNode_version folders
Use "nvm use NODE_VERSION" to switch between either version I've installed [but be careful... "npm -v" did not work until in visual studio until I closed and re-opened the program]
If anyone knows how to point nvm to the up to date urls, it'd be great to know. I suspect everything would work fine when running nvm from powershell run as administrator
Follow this step
1.delete node and npm in path
To Find Path
which node
output
/c/Users/balaji/AppData/Roaming/npm/node
which npm
output
/c/program files/node.js
2.To list out version
nvm list
3.set node
nvm use version
To know remote version
nvm list available
To know local version
nvm list
Yet another answer because none of the others helped me.
Setup
Windows 11
Multiple accounts
Non-default install and symlink directories
I installed nvm using different directories than the default because this is necessary to avoid:
Issues due to spaces in the path
Issues when using nvm on two different accounts on the same machine
Solution
This solution works for any number of accounts on the same machine.
Uninstall any nvm and nodejs you have.
Make sure no directory from them remains (in Program Files, Program Files (x86) and any other place you might have tried installing nvm/nodejs)
Reinstall nvm with:
An installation path that contains no spaces, and is not in any specific user's directory (e.g. C:\nvm)
A symlink path that contains no spaces, is not in any specific user's directory, and is not under nvm's directory (e.g. C:\nodejs)
Open your shell as administrator, install your desired node version(s) (e.g. nvm install lts) and activate one (e.g. nvm use 18)
Test that the version was activated correctly with nvm current and node --version
Every time you change your node version with nvm use or install a new one with nvm install, do it in an administrator shell
None of the above helped in my case.
I could see the symlink was created and correct but NVM4W would still not "use" the correct version.
The node version I had installed with NVM was not compatible with my version of Windows.
When you run "nvm ls" or "nvm current", it calls GetCurrentVersion() which runs "node -v" in the command line. If that output is anything other than the current version, such as the warning that you are running an incompatible OS, it will fail to indicate the currently selected version. It does so in a way that is not obvious why "nvm use x" did not work.
You can bypass the node OS check with an environment variable (node version >=14 as far as I could find):
How to set the NODE_SKIP_PLATFORM_CHECK environment variable to 1 which skips the version check
Though you may need to update Windows or use an earlier version of node if node doesn't function as expected.
With that set, "nvm use" functioned as expected.
I met this problem this morning. And I think the reason for the problem is that it's different between the nvm's settings and env configuration. I solved it the following way.
open the path of nvm installation.
open the setting.txt file and have a check with the path value.
open the environment variables Control panel in Windows.
check if it's the same between the value of NVM_SYMLINK in the system path and path in the setting.txt
change two configuration to same values.
Mine was caused by EMSDK. which I set on my .zshrc to load it automatically. removed the emsdk related lines, and the node was following nvm.
On Windows uninstalling Node.js at Control Panel > Programs > Uninstall a program, and letting nvm install the desired node versions also solves this issue.
In my case the things didn't work as described inside CI/CD service (TeamCity to be exact). I spent half a day, trying to find a solution and tried everything mentioned here and other similar questions. So, what worked:
Perform a clean install of nvm (removing older standalone versions of nodejs fist), as specified by multiple other answers. Install node versions only using nvm.
Make sure that process that is running your "nvm use" command has "Full Control" privilege to the root of nvm installation. So that it could delete the symbolic link "nodejs" folder when switching versions.
Change a policy on your server to allow that same account creating symbolic links:
This point was, somehow, not mentioned by anyone anywhere, so it took me very long time to figure this out.
I tried to use pip install, but it tells cannot find such package.
I also see someone say we can use brew and nodejs to install. This is what I tried to install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
It returns that ruby doesn't found.
I have no idea about nodejs.
Anyone knows how can I install PhantomJS in the server?
Meet npm!
Npm stands for Node Package Manager.
You can install packages for using them from the CLI or from your nodejs app.
You can install NPM from here.
If node isn't installed yet, you can use NVM, which makes it really easy -
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
For your question,
See this specific package.
You can install it via:
$ npm install phantomjs-prebuilt
And then you should be able to: $ bin/phantomjs [phantom arguments] to run phantomJS from the terminal.
PhantomJS is a standalone application with its own website which has binaries for all major platforms and documentation. You don't really need pip or npm or bundler to install it, just do it manually.
Go to http://phantomjs.org/download.html
Choose the appropriate binary (Linux x32 x64 / OSX / Windows), download archive, extract it and run the binary.
For example you have a x64 Linux distribution.
Log in to your server via ssh.
Go to your home directory:
cd ~
Download PhantomJS binary:
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
Extract archive:
tar xvf phantomjs-2.1.1-linux-x86_64.tar.bz2
A new directory is created: phantomjs-2.1.1-linux-x86_64. The PhantomJS binary is phantomjs-2.1.1-linux-x86_64/bin/phantomjs. You can run it right now:
~/phantomjs-2.1.1-linux-x86_64/bin/phantomjs --version
2.1.1
(If it says "not found " instead that means you chose the wrong distribution, e.g. x64 instead of x32).
But this way of running it is inconvenient. It would be way better to be able to just type phantomjs script.js in any directory. To make it so add a link to a directory where binaries are kept by default:
sudo ln -s ~/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin/phantomjs
Then you can call PhantomJS from anywhere:
cd /var/www/
phantomjs --version
2.1.1
I want to install the latest minor/patch version of NodeJS 4 using nvm. I don't just want "latest", because that would be NodeJS 8 or whatever later, potentially breaking-change version is out now.
If it were an npm dependency, I would be able to say nvm install "^4", but that doesn't work. Is there a simple command to do this? If there isn't, is there something I can do on the command line to find the latest version and install it in a one-liner that works on both Windows and Unix-based consoles?
(nvm maintainer here)
If you run nvm --help (make sure you're using the latest version of nvm), you'll see a description of all the things nvm supports. Specifically, nvm does not support semver ranges, however, nvm install 4 or nvm install 4.x will install the latest available version of node 4.
Separately, you can use nvm install --lts=argon (and nvm alias default lts/argon if you want to peg to the LTS line specifically instead of just v4.
I used Homebrew to install yarn. Running yarn -v shows that I currently use 0.23.2. I ran brew upgrade yarn to get the latest version, which is 0.24.6.
After Homebrew successfully upgrades yarn, I run yarn -v again, but the version is still 0.23.2. How can I change the version of yarn that I am running?
yarn policies set-version <version number>
Per https://github.com/yarnpkg/yarn/issues/7146#issuecomment-477809216
You can use homebrew and yarn formula URLs to install older versions of yarn, then brew switch between yarn versions as needed. Works perfectly! Credit to github user robertmorgan.
First off, if you already have a version installed, unlink it from brew running the brew unlink yarn command in your terminal.
Next, in a web browser, find the Pull Request that has been merged which contained the formula (version) of
Yarn
that you want to install.
View the files changed in that Pull Request - there should be one for Formula/yarn.rb.
Click the "View" button for the Formula/yarn.rb file to see the whole contents of the file for that commit.
Click the button to view the "Raw" version of that file. This will open a url which should start with
https://raw.githubusercontent.com/....
This is the URL that you will need for the next step - so copy the complete URL to your clipboard.
Back in your terminal window, use the command brew install followed by the URL that you've copied.
e.g. to install v1.6.0 of yarn it would be:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/fba7635ab69384ac980c635483a7af825bc06088/Formula/yarn.rb
You can then verify the versions available to Homebrew by running:
brew list --versions yarn, and switch between versions using brew switch yarn VERSION_NUMBER
Source: https://github.com/yarnpkg/yarn/issues/1882#issuecomment-421372892
I found an answer. It's not the prettiest, but since yarn always tell me what the most update-to-date version is, I can use npm to just install the latest version.
If the latest is 0.24.6
npm install --global yarn#.24.6
EDIT:
According to yarn's official documentation, the way to install/upgrade is:
brew install yarn
brew upgrade yarn
https://yarnpkg.com/en/docs/install#mac-stable
Your best bet would be to use a yarn version manager.
Install:
curl -fsSL https://raw.githubusercontent.com/tophat/yvm/master/scripts/install.sh | bash
Single usage:
yvm exec <version> <command>
Or to switch your currently running yarn version
yvm use <version>
yarn --version
UPDATE Dec 2021:
Sadly brew switch is deprecated in Homebrew 2.6.0 (December 2020)
$ brew switch
Error: Unknown command: switch
TLDR, to switch version:
brew unlink yarn
brew link yarn#<new_version>
Old solution:
Assuming that you have the other version installed, you can run
brew switch yarn <old_version>
To list the versions you have installed:
brew list --versions yarn
You can use
yarn set version <version>
For example, if you want the latest version, you can run
yarn set version latest
You can also set it to a specific number, for example,
yarn set version 1.22.1
You can view the full documentation at the official website.
Note 1: A bug stops you from switching from yarn 2 to yarn 1. There are solutions to this in this GitHub issue.
Note 2: I don't use brew, but this solution should still work.
Easily install and switch between any number of yarn versions.
https://github.com/tophat/yvm
Here's a way to do it with only curl and bash:
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.24.6 # or another version
This works whether you have yarn installed or not.
For updating version on macOS use below command:
$ brew upgrade yarn
Some of the above answers don't seem to work anymore. Here is how I was able to install a different version in April 2021:
brew unlink yarn#1.6.0 (If you already have a version installed)
brew extract --version 1.22.4 yarn homebrew/cask
brew install yarn#1.22.4
yarn -v