-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
npm fails: "Cannot find module 'semver' (node v8.4.0) #302
Comments
This is an npm error, not entirely an NVM error. I'd suggest reinstalling node 8.4.0.... perhaps the npm download was bad or something was corrupted. |
@coreybutler It won't work, keeps failing even deactivating, uninstalling, manually removing the folder reinstalling and reactivating. Same error. I even copied the npm's node_modules dependencies from another working normal installation of node 8.5.0 and still having troubles. Could you look more into it, and see what the problem is? The nvm is a really handy tool but not working anymore, and it's a pity :( |
@coreybutler just opened a new issue with the details |
My own environment and the steps I used to replicate the issue here (closed duplicate): #305 |
Same on the latest 8.8.1. Workaround
|
thanks @roman-spiridonov just ran into the same bug on node 8.8.1 installed via nvm on windows and your workaround seems to do the job |
Seems to have also worked using the latest version of node (9.1.0). |
seems npm thats installed from npm doesnt compatible with the node itself, you must download the zip and replace the npm module like @roman-spiridonov suggested |
@coreybutler is this not going to be addressed? I am seeing the exact same error exactly - anything above =< 8.0. Unfortunately, I can't run |
@roman-spiridonov I don't find that "npm" is a folder, but a file in the downloaded .zip. Replacing it with the downloaded one doesn't seem to resolve the semver issues for me (I know others have been successful) |
I have the same problem. The @roman-spiridonov 's workaround work for me.
|
@hyndsite you need to look inside the node_modules directory - inside that is npm directory. Use that and it should work. |
Thanks @powellian I found that yesterday and was going to post a new update to @roman-spiridonov message - that the correct path is The "npm" file in the /nvm/vx.x.x path helped to confuse the matter. |
Thank you, it works, But now I am wondering why is the package that nvm downloads & the one we download is different ? |
Same problem with 8.9.0 and @roman-spiridonov's workaround saved the day. Like @benavern I'm curious why the package nvm installs is different from the one in the official repo. |
Same on the latest 8.9.4. |
Workaround:If you encounter this issue and you're using Windows 10, enable long paths using Registry Editor or Local Group Policy Editor. Ref: #305 (comment) But for me, I still needed to do @roman-spiridonov's workaround. However, I couldn't copy npm folder in Explorer, instead I needed to use robocopy:
|
alternative it to move nvm root. do
|
I experienced the same problem (Error: Cannot find module 'semver'). Some hints to get you going: File compare (using official zip file) showed that there are indeed > 4k files and folders missing under I took the current master of nvm-windows, added some debug information to the install function within
Now for the surprising part, as I tried finding the regression:
It looks for me like there is an issue with the build process and/or environment. Would be great if someone else could try if recreating the nvm.exe via build.bat or HTH, codeshell |
Delete npm folder from below folder |
Just ran into this issue today and this worked for me.
|
@codeshell Thanks for your analysis. I found the issue to be due to the long paths that are not supported on Windows. For me even after downloading npm zip file and replacing contents of C:\Users\yourname\AppData\Roaming\nvm\9.11.1\npm I got the error. In fact I could not copy all files from downloaded npm zip file due to long names. To avoid this I uninstalled node version 9.11.1, then uninstalled nvm. Reinstalled nvm at C:\nvm. Now my normal 'nvm install 9.11.1' works just fine and 'npm' is also in good state confirmed by running 'npm -v'. I know this is a pretty drastic fix but just need to do one time. |
I followed These steps and it solved my issue
|
installing the node through nvm 1.6.0 worked for me |
In my case, the paths were just too long. I chose c:\nvm as the install directory version manager and c:\nodejs for the symlink directory. That seemed to resolve the issue for me. |
I had the same problem with node v10.4.0 and the workaround from roman-spiridonov worked for me. I had already removed |
Tried getting 10.4.1 up and running, had problems at first. Got it to work after deleting the folder from install location manually and installing via |
Same problem with v10.5.0 and roman-spiridonovs solution worked for me as well. |
I have the same probem when installing the latest node v10.6.0, then I just uninstalled it and switched to v8.11.3, problem solved. I also tried download directly the npm-v6.1.0.zip, it do have some errors when unzipping. |
Experienced the same issue as @shadeofgod with 10.6.0. Switching to 8.11.3 solved it. |
problem persists with 10.6.0-64bit for a complete clean first install. (no node/npm before). roman-spiridonovs solution continues to work (for me the npm-folder can now be found in |
Why is this still an issue after almost an entire year? |
os.Rename() of node_modules/npm on Node version installs throws Access Denied (win 7) -- seems to be this issue coreybutler#302 and that seems to be caused by a golang behavior change in os.Rename() described in golang/go#14527 ...fixed by using copy package instead
Just encountered this issue on Windows 10. Enabling Win32 long paths fixed the issue. See post from @apptaro (2018-02-15) After enabling long paths, I rebooted Windows to make the change apply. After that, I could install the I feel, |
For me:
This is the powershell script we use for new starters. Hopefully after a reboot they should be able to update to a later version is the idea. # Get Chocolatey which is required for the rest of this script
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco feature enable -n=allowGlobalConfirmation
choco upgrade chocolatey
choco upgrade nvm
$env:NVM_HOME = [System.Environment]::ExpandEnvironmentVariables([System.Environment]::GetEnvironmentVariable("NVM_HOME","Machine"))
$env:NVM_SYMLINK = [System.Environment]::ExpandEnvironmentVariables([System.Environment]::GetEnvironmentVariable("NVM_SYMLINK","Machine"))
$env:Path = [System.Environment]::ExpandEnvironmentVariables([System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User"))
# Enable long paths in windows - may avoid npm issue https://github.com/coreybutler/nvm-windows/issues/302
New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1 -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path 'HKLM:\SYSTEM\ControlSet001\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1 -PropertyType DWORD -Force | Out-Null
nvm install 9.11.2
nvm use 9.11.2 |
I believe @momochanmo had just forgotten to install the semver package in their project. It has the same error message but this is a totally different issue. To recap: This thread is about the fact that nvm installs a corrupted version of npm with a missing/corrupted version of the semver package, which renders it inoperable. The most likely root cause suggested so far is that a bug / behaviour change introduced into the Go compiler about 3 years ago causes an error that's being silently swallowed during installation. See #370. So if you know someone who works with Windows stuff and is enthusiastic about Go, now's a good time to tap them on the shoulder and offer them this excellent career development opportunity 😅 |
Following this worked for me. You are a life saver!!!!! thanks <3 |
I am using NVM for Node versions 10.21.1, 10.23.0, 12.20.0, 14.15.4
However, if I specify the actual location of npm - that works: I have tried:
npm -v will not run - semver error nvm version 1.1.7 |
If this is a question about how to use NVM4W, please use stackoverflow instead.
If this is an issue regarding antivirus, make sure you search the existing issues first.
My Environment
Windows 7 or below (not truly supported due to EOL - see wiki for details)
Windows 8
Windows 8.1
Windows 10
Windows 10 IoT Core
Windows Server 2012
Windows Server 2012 R2
Windows Server 2016
My Windows installation is non-English.
I'm using NVM4W version:
I have already...
My issue is related to (check only those which apply):
Expected Behavior
Return correct version number.
Actual Behavior
module.js:491
throw err;
^
Error: Cannot find module 'semver'
at Function.Module._resolveFilename (module.js:489:15)
at Function.Module._load (module.js:439:25)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
at Object. (C:\Users\leofu\AppData\Roaming\nvm\nvm\v8.4.0\node_modules\npm\lib\utils\unsupported.js:2:14)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
module.js:491
throw err;
^
Error: Cannot find module 'semver'
at Function.Module._resolveFilename (module.js:489:15)
at Function.Module._load (module.js:439:25)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
at Object. (C:\Users\leofu\AppData\Roaming\nvm\nvm\v8.4.0\node_modules\npm\lib\utils\unsupported.js:2:14)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
Steps to reproduce the problem:
nvm install 8.4.0
nvm use 8.4.0
npm -v
The text was updated successfully, but these errors were encountered: