While running npm command I get the error
Error: Cannot find module 'C:\Windows\System32\node_modules\npm\bin\npm-cli.js'.
I tried uninstalling and installing nodejs but with no luck. Also I tried configuring the env vars
I'm not entirely sure about this, but I dont remember having nodejs/npm installed in Windows directory. It should be in your Appdata somewhere. Your install Paths maybe somehow corrupted
But here is a possible solution:
Go here:
Install it and run the following commands:
nvm list
nvm install [version]
for example:
nvm install v10.15.3
The Command should automatically select the installed version as default.
For further information check their Github Readme.
If they don't work right off, be sure to restart the Version Manager OR be sure to follow the instructions led out by the Github Readme.
Version Manager have one big benefit: The Community keeps them updated and because they use different Path architectures they can be installed at places where they weren't originally meant to be from the original installer which lead to a whole different outcome for you because they probably will not install directly into System32.
Other Node Version Manager you could check out (should all be Windows):
https://github.com/hakobera/nvmw
https://github.com/nullivex/nodist
Hope it helps!
Related
Global install of typescript doesn't appear to install correctly on windows.
Steps to reproduce:
.Using node v16.16.0 (64bit)
.Then 'npm install -g typescript'
.I can confirm environment path variables contain:
'C:\Users{MyUserName}\AppData\Roaming\npm' and
'C:\Program Files\nodejs\node_modules'
The node_modules/typescript/bin folder appears a follows:
As seen, a tsc file does exist, however the expected tsc.cmd doesn't.
This is required for windows to execute.
My assumption is this must be system or permissions problem whereby node can't create the tsc.cmd, not necessarily and issue with the
typescript package
Image for reference:
//----------------
Additional notes:
I have also tested this on 10.24.1 using nvm, this is now uninstalled
I have ran these steps on another machine, without problems countless
times.
I have uninstalled (completely) nvm and node before attempting this
multiple times.
I have performed a complete system search for tsc.cmd I do have
wsl installed, perhaps there is some interference there?
Results from suggestions this far:
Running locally on a project (Niceman)
I think this is an issue more related to your node path in your environment variables. To test this, install something else globally, like sass for example.
Then you can try sass --version. If it doesn't work the it's probably that your node path is messed up. You can try uninstalling node and reinstall it with the last LTS installing file from the official site. Then you can try to installing typescript again. If that doesn't work you'll need to open the environment variables and check your path for node modules.
Another possible solution is to try using another command line, because maybe a Powershell config is messing up this things. You can try installing git bash. It's not the best, but works.
Solution: use yarn!
As mentioned, I am missing tsc.cmd whatever method I choose (win 11). Who knows what the cause is.
By using yarn :
Delete the dudd folder under your node_modules folder from any npm attempts
yarn global remove typescript
yarn global add typescript
add 'C:\Users{yourUserName}\AppData\Local\Yarn\Data\global\node_modules.bin' to your path
As mentiond, you now have the required tsc.cmd:
What a ride ey!
I'm trying to install LESS css in Netbeans, but I'm running into one problem after another. As such, I already have LESS installed, but I can't get it running.
Less is installed via the npm package, I installed it using the packaging system, less itself via Terminal. The first problem I had was that despite a successful installation, Netbeans didn't get to the files he needed (usr/local/), I could either change permissions there, which I don't want to dig into, or change the location. So I changed the location of the .npm and .npm-global folders to my root (home/ivet/), from where Netbeans managed to load it.
So I set everything there, the general settings and the specific project and it looked fine.
I want it to be converted to css automatically after saving, but it throws the message "/usr/bin/env:"node": Directory or file does not exist" and the target css file is still empty.
I found a few advices, basically the same: "ln -s /usr/bin/node/ usr/local/bin/nodejs", but it tells me that the link already exists and nothing will solve it. On closer inspection, I found that the link does exist, but the target file does not exist.
I've also found that installing Nodejs legacy solves this, but this is an older piece of advice, the package no longer exists, and terminal pretends to have the packages that replace this installed. Even when searching for via grep, I couldn't find the file it should link to (neither node nor nodejs).
There are the same tips everywhere that don't work for me and I don't know what to try next. I use Linux Mint 20, but I call myself a Linux BFU, so please write answer step by step :-D
Thanks for the advice
Try completely removing NodeJS & npm and try to install NodeJS using nvm i.e., node version manager.
You can follow this link on how to install nodejs and npm using nvm.
It's always a tedious task sometimes when it comes to package managment with npm, so it's better to go with nvm and I strongly suggest to always have a fallback option for node version when using with or without nvm i.e.,
NodeJS LTS version & NodeJS latest/stable version.
There's also an alternative solution i.e.,you can try switching to yarn package manager.
I've had this issue on Ubuntu and I've resolved it likes this:
First of all I've removed node and npm packages via
sudo aptitude remove node npm
Then I've added the official repositories
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
After which I've just updated the list of packages with sudo aptitude update and then installed Node
sudo aptitude install nodejs npm
And that was it. With these steps done, everything just started to work.
The official node documentation says just run the installer from the latest version and it will overwrite the old version. It doesnt in my case for some reason.
node --version
gives 0.10.26.
I downloaded and installed 6.10.0 LTS from the node site.
node --version still gives 0.10.26 (including after reboot)
I have read many posts on the subject, and other people suggest
npm install update
this downloads some files, but node --version still gives 0.10.26
In add-remove programs, there is only 6.10.0, no 0.10.26, so dont know how to uninstall this old version.
Any ideas where I can get an uninstaller from, or how to manually uninstall the old version?
Note, I dont want to complicate things with one of the many tools for managing multiple versions of node as this is likely to add more complexity and problems, I just want to get the latest node if that is possible.
Searching my hard drive, i found there is nodejs installed in program files. Its not easy to know what version this is, but the CHANGELOG.md says version 3.1.0. I have no idea where 0.10.26 is installed to, nor 6.10 for that matter.
I cant see anything like NODE_HOME in my env vars, but c:\programfiles\node\nodejs is in the PATH. Although add-remove programs tells me 6.10 is installed, I dont see how or where, or how to uninstall 0.10.26
Any ideas?
=== update ====
To make it even more confusing, I tried CDing into c:\program files\nodejs and ran "node.exe --version" This DOES give 6.10.0. So the only version of node which seems to be on the machine, and the one my path points to, is 6.10, but when I run "node --version" in any other directory, I get 0.10.26.
Well, by luck, I found the problem. I went through every item in my path and found something called baboonstack, which I had never heard of. Uninstalled that, and get 6.10.0! Good times!
Using the newest node.js installer from https://nodejs.org, I run into the same error every time when it reaches the npm installation. npm 3.x was supposed to deal with this issue, but apparently it doesn't help the node.js installer. The node developers have essentially refused to do anything about it, as this problem has been around for about two years already. Unfortunately, I can't seem to find a work around. How can I get this to install?
I also had this error, trying to install node-v8.10.0-x64.msi on Windows 10.
My solution (to getting it to install; no idea if it won't break further down the line) was changing the install directory from C:/Program Files/nodejs to C:/njs/ (2nd step of current setup process).
I'm surprised those characters made the difference, and that there even is a Windows node release if there's not a proper solution to this (can't believe that maximum path length on Windows isn't modifiable), but this has seemingly worked for me.
I don't think its an installer error, actually windows is restricting the path size to be 150 char.
try reducing the file path name by copying it into direct c or d drive.
Check the link below Microsoft Forum
I've used Choco
It works together with NVM 4 Win.
After once installing node with choco install nodejs
then I install other versions of node using NVM e.g. nvm install 6.9.0
following by choosing that version with nvm use 6.9.0
and then verify with nvm list
and node -v.
I also need to install the latest version installed by choco using nvm install 10.1.0
I have recently started playing with node.js, but I got lost in a big mess of different versions of node, npm, nvm and other packages. I don't know what is installed globally and what is installed locally (and if locally, how do the packages know which versions of node they can use?).
I'd like to have some summary of what different installation options do. In specific:
Where is node installed when I use nvm, apt-get, make install or when using other ways?
Is it a good idea to install node locally?
Why does nvm change my ~/.profile instead of installing itself in some system-recognizable bin folder?
I saw that nvm can install different versions of node alongside each other - why would I want to do this? I can install them locally instead, right?
Where does npm install packages? I saw that it checks packages aganist version of Node, what happens to these packages when node is upgraded?
In what cases it is better to use global or local installation? Where should I put my packages then (and where they put by default?)
What's the difference between npm, nvm and nave?
EDIT: There is a lot of ways to install node here, this makes me even more confused...
Where is node installed when I use nvm, apt-get, make install or when
using other ways?
apt-get installs all the software, not only node, on the file system following the Ubuntu convention where to store binaries, man files, shared files, logs, etc. However, using apt-get you'll have only the certain version of node which is determined by the distribution release cycle. If there are updates available they will be installed with apt-get update; apt-get upgrade However, the newest version of some app won't be available until it makes its way into the distribution. For example node v0.x.y might not be available until Ubuntu 13.10 the only way to get will be to install it manually. The good side of apt-get or other system package manager is that it manages updates and package removal for you. It stores all the data about the software package in it's own database. You can always delete the node with apt-get remove node and that's it.
make install install the package manually, but it is considered harmful. Never use the make install mainly because you won't be able to delete the package easily, you'll have to read the Makefile and manually delete all the files installed by it. In a situation where you want to use make install there is always checkinstall available. It's a software which creates a native package and registers it with the system. When you decide to delete the package you could do this with one command instead of many. wiki link; Ubuntu guide on checkinstall
Now nvm script is a node version manager. It is very helpful and easy to use. It allows you to have multiple versions of node to be installed and used in parallel on your machine. It doesn't compile the node from source like make install so it is very fast. it doesn't depend on your distribution release cycle so you have access to all the node versions available at the moment. nvm downloads precompiled binaries and is perfect for general use. It stores it's node files in it's own folder locally so in case you want to compare something between the different node versions it's easy to do.
Is it a good idea to install node locally?
If by locally you mean using nvm then it's very good for development, and testing. Not sure about production performance implications and benefits between having it's installed from source or using the nvm precompiled binaries. I use nvm for development and installed from source in production. However if someone could explain this issue any further I'll be glad to learn more.
Why does nvm change my ~/.profile instead of installing itself in some system-recognizable bin folder?
Because nvm isn't an executable. It is a set of bash functions which are sourced by shell and could be used separately. You can invoke nvm_ls and nvm_ls_remote and others without the main script after is is sourced into your shell. What the main script does it parses the command line arguments and pretty prints the output in case of for example `nvm_ls_remote'.
in the ~/.profile the following line is added
[[ -s /home/USERNAME/.nvm/nvm.sh ]] && . /home/USERANME/.nvm/nvm.sh # This loads NVM
loads all the functions into your shell
I saw that nvm can install different versions of node alongside each other - why would I want to do this? I can install them locally instead, right?
You can install them locally using make install or checkinstall but you will have to make aliases for them like node_0.8.1, node_0.8.2, node_0.10.1 , etc. AND you'll have to manage new aliases, installing all the packages, removing them in case you don't need them YOURSELF. These are a tedious and boring tasks which could be error prone sometimes. nvm does all of these tasks for you for free.
You want to do this to test your app under the different versions of node. For example you are good and tested under the v0.8 but you want to use the new features of the v0.10.3 how do you do that ? You have to download the source code, compile, make an alias and run your app. you could do this with just nvm install 0.10.3 and run your app.
Sometimes you have to support more than one version of node. For example some hosted environments are not keeping in touch with the latest release and only have v0.6 Your clients which use your server app might encounter a bug specific to this version. When you fix the bug you have to reproduce it first. Using nvm installation of the v0.6 is one line and half a minute. And you can check all the versions you want this way easily. Test your code under different versions and make sure you are good to go.
Where does npm install packages? I saw that it checks packages aganist version of Node, what happens to these packages when node is upgraded?
If you are using nvm the packages which are installed globally with -g option are tied to the relevant node version. When you switch between versions with nvm use 0.x you have to either install the packages again or use nvm copy-packages <version> to use the packages from in the current version. If the packages are installed locally then it depends. package.json should contain info on the dependencies of the app. If it says node: '0.8' and you just updated to 0.9 you might encounter troubles. For example the behavior of process.nextTick was changed in the latest releases compared to 0.6. So be careful.
In what cases it is better to use global or local installation? Where should I put my packages then (and where they put by default?)
It depends. For development nvm is superior in my opinion. For me it is convenient and simple. For production there are might be some performance implications when using the precompiled binary files not optimized for your system. It would be better to ask this as a separate question so the people with the relevant experience could answer.
What's the difference between npm, nvm and nave?
npm is a node package manager -> link It contains userland packages developed by other people. These packages are not part of the node core. npm is used for publishing your code and dependency management. If your app requires other app developed by other people it is convenient to publish it via npm.
nvm is a node version manager it does a completely separate thing. It gives you an ability to very easily switch between node versions on the same machine and manages all he changes in your $PATH environment variable.
Consider nvm as update manager for the Operation System and npm as a manager of the applications for this system. Well, this comparison isn't precise but just came upon my mind
nave is basically the same as nvm but it is an executable whereas nvm is a script which is sourced into the shell. Each system has it's own benefits. You could make a separate question regarding it's use cases and differences.
My answer isn't 100% complete and contains a lot of subjective personal opinions. However, I hope I'll at least make some points more clear so you might proceed with other more specific questions. Btw, this question list of yours could be asked as separate questions. I believe stackoverflow gives best results when specific questions are asked separately and more people with relevant experience could contribute.
If you run
npm install
in folder with package.json, it installs all packages localy (in the current folder).
Also, npm default install packeges local. To install it globaly - use -g flag:
npm install -g <package>
Execute next command:
npm config list
You see all npm config description.
You can install modules in the local context of your application with
npm install modulename
In this case the module will be installed to your node_modules folder of your application.
Otherwise you can install a module in the global context with
npm install -g modulename
In this case the module will be installed for the hole system environment usually at /usr/local/bin/modulename.
The global installation makes sense for modules you need in more than one application, like express or node-inspector.