I am using direnv and an nvmrc file to force nvm install to run every time you cd into the directory, making sure if you are running the project you are using the correct node version.
However, I noticed that if someone else changes the nvmrc file's version and I git pull (or rebase) the change, it doesn't automatically update my node version because it only runs when I enter the directory.
Has anyone done something to watch the nvmrc file or somehow make it change more often than just on cd?
Since direnv's .envrc file is evaluated at each prompt, for your use case I would just place an explicit nvm install <version number> in your project's .envrc, e.g.:
nvm install 10.16.0
Although, personally, I prefer to just have an nvm use <version number> and let nvm itself point out that a given version of node isn't installed yet if the requested version isn't available.
Related
Is it possible to install a yarn dependency as an editable dependency?
I'm looking for something like python pip's:
pip install -e
For local development of a library. My goal is to see changes in a package I'm developing while simultaneously using it in another package.
You can directly edit the files in node_modules and changes there are reflected immediately, but also overwritten when yarn decides to update the module. Note, that some files need to be built first or might be a bit tricky to edit (minified / transpiled build artefacts). You can also install the module directly from GitHub, if this is easier for your development process.
Apart from that, there is no such thing as "editable" dependencies in npm / yarn.
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"**
today I noticed that I couldn't execute some node.js programs (e.g. weinre) from the shell by typing $ weinre. But I had it installed (two versions even) in ~/.npm/weinre/2.0.0-pre-2012-03-02--15-31-31/package/weinre and in ~/.npm/weinre/2.0.0-pre-H41DGW8S-incubating/package/weinre. To top it off, I also have a ~/local/node_modules/ path, but there's only socket.io. (I'm on a Mac and ~/local/ is in my path, I use it instead of /usr/local/).
So it appears that node modules can be in ~/.nvm/v0.8.1/lib/node_modules, in ~/.npm (with version number and "package" subfolder) and in ~/local/node_modules. So where should they go?
I ran npm install -g weinre which installed an alias to ~/.nvm/v0.8.1/bin/weinre. The alias points to ~/.nvm/v0.8.1/lib/node_modules/weinre/weinre. I still have the other two weinres in the ~/.npm/weinre path written above.
Something seems to be broken here...can someone please explain or help to fix it? :(
(nvm maintainer here)
Everything in ~/.npm is npm's cache; you shouldn't be looking in there or concerned with it at all :-)
Your global node modules will be in npm root -g. ~/.nvm/v0.8.1/lib/node_modules is that path for the nvm-managed node version 0.8.1; ~/local/node_modules is probably that path for your system node.