Cannot find module 'C:\...\node-gyp\bin\node-gyp.js'
See original GitHub issueHi! I’m trying to use node-gyp but when I call node-gyp
in shell it throws me this error
if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" build ) else (node "" build )
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\node_modules\node_modules\node-gyp\bin\node-gyp.js'
←[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:725:27)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)←[39m
←[90m at internal/main/run_main_module.js:17:47←[39m {
code: ←[32m'MODULE_NOT_FOUND'←[39m,
requireStack: []
}
What should I do?
I tried to install windows-build-tools
originally npm i -g windows-build-tools
it installs for eternal but npm i -g windows-build-tools@4.0.0
works
Issue Analytics
- State:
- Created 2 years ago
- Comments:20 (9 by maintainers)
Top Results From Across the Web
Error: Cannot find module 'C:\Program Files\nodejs ... - GitHub
It's uncertain why I am getting this error after running npm cli command. Is it because nvm is pointing to that same path?...
Read more >node.js - Error: Cannot find module 'C:\Program Files\nodejs ...
Navigate to C:\Users\%USERNAME%\AppData\Roaming\npm\node_modules and paste the copied npm directory there.
Read more >cannot find module [Node npm Error Solved] - freeCodeCamp
In my case, I got it like this "Module not found: Error: Can't resolve 'react-icons/fa' in 'C:\Users\user\Desktop\Projects\Address Locator\ ...
Read more >Cannot find module (node.js / npm) - javascript - Super User
I run the command "node run index.js" but I keep getting met with an error saying:
Read more >Fix Global Installs Not Working | "Cannot find module" error FIX
Getting " Cannot find module " after installing something globally (with -g)? Well, this video shows you how to fix global package/module ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
another my guess is that, as i saw, you have added wrong node-gyp to your PATH variable: you have added node-gyp from internals of npm, but not from global node_moduels location (by default
%APPDATA%\npm
). When you have runnode-gyp
it has executed node-gyp from internals of npm and because npm uses magicalnode-gyp.cmd
to launch the node-gyp itself, you got such strange error.The solution is:
Win
+R
SystemPropertiesAdvanced.exe
and pressEnter
Environment Variables
button in bottom right corener of the windowPath
var in User variables area and pressEdit
appdata\roamning\npm
, select it and pressup
button on the right side of window so many times until the line will not be higher than all ones which containC:\Program Files\nodejs\node_modules\npm
By moving this line up, we raising priority of this path, that mean windows will earlier check this path than others (especially wrong one).
After doing this restart your terminals and try to run
node-gyp
as in original comment. But i have heard that it is not recomended way to do the stuff. better run commands vianpx
PS. more clear guide how to change env vars
According to this https://github.com/nodejs/node-gyp/issues/2272, you should try to run
npm config delete node_gyp
.My thoughts are that somewhere in configs is a line which tells to npm to use
'C:\Program Files\nodejs\node_modules\npm\node_modules\node_modules\node-gyp\bin\node-gyp.js'
path which contain excessnode_modules
path segment. The above line should delete wrong line from config