Skip to content

Common Issues

Corey Butler edited this page Sep 30, 2021 · 58 revisions

There are a couple of common issues folks run into. I try to fix them/accept PR's when possible, but there are a few things I've simply held off on. Why? I'm building a new version that's cross-platform compatible, and I'm trying to get infrastructure setup for things like auto-update.

In the meantime, here are some common issues and workarounds:

Permissions (Exit 1, Exit 5, Access Denied)

By popular demand, NVM4W 1.1.8 introduced support for developer mode. In other words, you won't receive a UAC prompt to elevate permissions if it's not explicitly necessary. If you prefer to be prompted for UAC rights, use NVM4W 1.1.7.

If you do not run the nvm.exe file with appropriate permissions, you may receive an exit 1, exit 5, or Access Denied error. These come straight from Windows, indicating the user account does not have permissions to do what you're trying to do.

The most common permission issue has to do with creating symlinks. NVM4W uses symlinks (mklink is used in nvm use) to redirect the Node installation path to the appropriate installation. Windows requires elevated administrative privileges to create symlinks, but developer mode eases these restrictions.

It's best to enable developer mode on Windows 10, which will grant your user account slightly elevated permissions. See how to Enable Your Device for Development

Enable Developer Mode

The second most common permission issue is trying to use a protected directory for storing Node installations. Windows requires administrative privileges to write to C:\Program Files. Many users want to install different versions of Node to this directory, but this forces NVM4W to create download (write) Node/npm to a protected directory. It's typically simpler to store Node installations in an alternative directory, such as C:\nvm4w.

Several people have complained about protected directories, and I'm sorry... but I'm not the person to talk to about that. Your best bet is to reach out to Microsoft, because it's an operating system requirement. Every program has to deal with this. Remember that NVM4W is basically an installer, so it needs installer-like permissions.

The third most common permission issue is conflicting permissions. Many users fail to uninstall old versions of Node before installing NVM4W. The NVM for Windows installer attempts to migrate existing Node installations into NVM4W, but old installations can prevent this. The original Node installation is often installed with different user permissions, making it impossible for NVM4W to uninstall it. This results in two conflicting installations of Node. Node can physically exist in more than one location, but only one unscoped (i.e. globally available) version can be used at a time. This is why the README recommends uninstalling previous versions of Node before installing NVM4W.

Antivirus

Some versions (particularly 1.1.8 and nvm-update.exe) are not code-signed. Some antivirus services use machine learning algorithms to determine threats on unsigned executables. If your antivirus recognizes a threat with a name like !ml, ML or .ML, it indicates a machine learning algorithm is making a guess about the application. These are not the same as known virus signatures. NVM4W has no malicious code, but version 1.1.8 is not code signed. See the release notes under the WARNING section for details.

After an undetermined number of installations, Microsoft Defender and Microsoft SmartScreen will trust the application. However; there is no way of knowing what that number is. You may need to make an exception in your antivirus for NVM4W.

If you cannot download a release, you may need to temporarily disable realtime protection. Always remember to turn this back on after your download completes!

disable windows defender realtime

Take note that running nvm-update.exe will download nvm-setup.zip, then extract all of the relevant files to update your installation and cleanup when done. You may need to temporarily disable Windows Defender realtime protection while doing this as well.

Spaces in pathnames/installation root

This issue should be resolved as of version 1.1.8.

If you are working with an older version...

Some environments aren't picking up on space-escaping. If you're having problems with Windows recognizing NVM4W, try installing it on a path with no spaces, like C:\nvm. The same situation is relevant for the symlink path, so you may want to use something other than C:\Program Files\nodejs for the symlink root.

Uninstall Existing Node Installation Before Installing NVM4W

The installer attempts to take over any existing installations of Node for you, but the process can be more complex than it appears. The most common source of problems is when users install NVM4W using a different account or with different permissions than those which are used to install prior versions. The bottom line is permissions for installing/uninstalling applications are quite strict and NVM4W may not be able to absorb prior installations.

The best course of action is to uninstall prior versions of Node before installing NVM4W. In some cases, you can uninstall prior versions afterwards, but the only reliable way I've consistently seen it work is by removing prior versions before installing NVM4W.

Depending on which version of Windows you have and how your desktop is setup, there can be issues with modifying a path in the registry for an application you don't control, user accounts associated with an existing app, roaming profiles, etc.

I only have a couple of versions of Windows to test on, but it's far from the complete Microsoft Windows catalog. Again, the one consistent solution that always seems to work is uninstalling Node before installing NVM4W.

Upgrading NPM

Some users experience the following error:

npm ERR! path C:\Program Files\nodejs\npm.cmd npm ERR! code EEXIST npm ERR! Refusing to delete C:\Program Files\nodejs\npm.cmd: is outside C:\Program Files\nodejs\node_modules\npm and not a link npm ERR! File exists: C:\Program Files\nodejs\npm.cmd npm ERR! Move it away, and try again.

The best bet is to use this solution, https://github.com/felixrieseberg/npm-windows-upgrade

Some older versions of npm have hard coded paths that prevent automatic removal. Several users have found manual workarounds that work well.

How do I use yarn with nvm-windows?

Yarn is an npm package. npm install -g yarn will install it. Remember, yarn is not officially released with Node.js, so this will need to be repeated for each new installation of Node.js.

Special Terminal Shells

Per issue #417, some shells do not respect UAC prompts (i.e. requesting administrator permissions). NVM for Windows cannot control how terminals work, and due to the sheer number of custom terminals available (mingw, cmder, ConEmu, cygwin, hyper, etc), only official Windows terminals are supported (CMD and PowerShell). Bash for Windows support may come in the future.

If you are using a special terminal that does not respect UAC requests, you may see errors like this:

mingw64

"The system cannot find the path specified"

If Windows cannot find NVM, try restarting the terminal/powershell first. If the issue persists, it may be due to a misconfiguration in the terminal. See this stackoverflow answer for a possible fix.

Clone this wiki locally