Struggling to set up MongoDB on Windows 7 via NPM

Hey folks,

I’m hitting a roadblock while trying to get MongoDB running on my Windows 7 machine using NPM. Even though I’ve got Python and VC++ installed, I’m still running into issues.

Here’s what’s happening when I try to install:

npm install nosqldb

> [email protected] setup C:\projects\web-app\node_modules\nosqldb
> node-gyp configure || (exit 0)

C:\projects\web-app\node_modules\nosqldb>node "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\node-gyp-bin\\..\\..\\node_modules\\node-gyp\\bin\\node-gyp.js" configure
  datastore.cc
..\src\datastore.cc(12): fatal error C1083: Cannot open include file: 'memory.h': No such file or directory [C:\projects\web-app\node_modules\nosqldb\build\datastore.vcxproj]

gyp ERR! build error
gyp ERR! stack Error: `C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\msbuild.exe` failed with exit code: 1

Any ideas on how to fix this? I’m pretty stumped at this point. Thanks in advance for any help!

  • Dave

hey dave, sry to hear ur having trouble. have u tried clearing ur npm cache and reinstalling? sometimes that helps. also, make sure ur using the latest version of node-gyp. if that doesnt work, u might need to manually install the windows build tools. good luck!

I encountered a similar issue when setting up MongoDB on Windows 7. The error indicated that certain C++ build tool components were missing, which led me to adjust my setup. I removed older Visual C++ Redistributables and installed the latest Visual Studio Community Edition with the Desktop development with C++ workload. I also set the MSBuild version in npm using the command npm config set msvs_version 2017. If problems persist, specifying the Python path with npm config set python C:\Path\To\Python\python.exe resolved the issue for me.

As someone who’s wrestled with MongoDB setup on Windows, I feel your pain, Dave. One thing that worked for me was manually installing MongoDB instead of using NPM. Head to the MongoDB website, download the MSI installer for Windows, and run through the setup wizard. It’s more straightforward and bypasses the node-gyp headaches.

After installation, you’ll need to set up the data directory. I created a folder at C:\data\db for this. Then, navigate to where MongoDB is installed (usually C:\Program Files\MongoDB\Server[version]\bin) and run mongod.exe from the command prompt. This starts the MongoDB server.

If you still prefer the NPM route, try using a specific version of MongoDB that’s known to work with Windows 7. Something like ‘npm install [email protected]’ might do the trick. Remember to run your command prompt as administrator too. Good luck!