[SOLVED] Node-gyp error, node_modules does not get created, please help

Hello, I am having an issue which is preventing me from doing the course on Windows 10

I am getting the node-gyp error.

According to the setup section, it is expected and shouldn’t affect anything.

However, it isn’t the case for me. The node_modules folder is created at first, then I see the node-gyp error, then the process terminates with

npm ERR! gyp ERR! not ok

and the node_modules folder is deleted. So I do not have any of the modules and cannot continue with the course.

Please help.

Here is the full error:

npm ERR! code 1
npm ERR! path C:\Users\user\programming projects\mflix-js\node_modules\weak-napi
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
npm ERR!   nothing.c
npm ERR!   win_delay_load_hook.cc
npm ERR!   nothing.vcxproj -> C:\Users\user\programming projects\mflix-js\node_modules\weak-napi\build\Release\\nothing.lib
npm ERR!   weakref.cc
npm ERR! c:\users\user\programming projects\mflix-js\node_modules\weak-napi\src\weakref.cc(2): fatal error C1083: Cannot open include file: 'setimmediate.h': No such file or directory [C:\Users\user\programming projects\mflix-js\node_modules\weak-napi\build\weakref.vcxproj]
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@15.11.0 | win32 | x64
npm ERR! gyp info find Python using Python version 3.9.2 found at "C:\Python39\python.exe"
npm ERR! gyp info find VS using VS2017 (15.9.28307.1440) found at:
npm ERR! gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn C:\Python39\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'msvs',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\user\\Documents\\programming projects\\mflix-js\\node_modules\\weak-napi\\build\\config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\user\\AppData\\Local\\node-gyp\\Cache\\15.11.0\\include\\node\\common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=C:\\Users\\user\\AppData\\Local\\node-gyp\\Cache\\15.11.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\user\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\15.11.0\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\user\\Documents\\Programming projects\\mflix-js\\node_modules\\weak-napi',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'C:\\Users\\user\\Documents\\programming projects\\mflix-js\\node_modules\\weak-napi\\build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'build/binding.sln',
npm ERR! gyp info spawn args   '/clp:Verbosity=minimal',
npm ERR! gyp info spawn args   '/nologo',
npm ERR! gyp info spawn args   '/p:Configuration=Release;Platform=x64'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:378:20)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\user\mflix-js\node_modules\weak-napi
npm ERR! gyp ERR! node -v v15.11.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\user\AppData\Local\npm-cache\_logs\2021-03-16T04_28_48_297Z-debug.log

Well, after many, many hours of wrestling with this problem and foregoing sleep, I finally found the issue…

I had a space in one of the folder names in the path to the project… “programming projects”

Changed it and no more node-gyp error!

3 Likes

Welcome to the MongoDB forums @Ali_Hassan!

Thanks for sharing the solution to your issue – hopefully that will help others who encounter the same issue find a faster solution.

Regards,
Stennie

Hi Ali! Thank you very much for your solution)
I spent the whole evening yesterday figuring out what is a problem about.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.