npm install error – MSB3428: Could not load the Visual C++ component “VCBuild.exe”

Try this from cmd line as Administrator optional part, if you need to use a proxy: set HTTP_PROXY=http://login:password@your-proxy-host:your-proxy-port set HTTPS_PROXY=http://login:password@your-proxy-host:your-proxy-port run this: npm install -g –production windows-build-tools No need for Visual Studio. This has what you need. References: https://www.npmjs.com/package/windows-build-tools https://github.com/felixrieseberg/windows-build-tools

Avoid “current URL string parser is deprecated” warning by setting useNewUrlParser to true

Check your mongo version: mongo –version If you are using version >= 3.1.0, change your mongo connection file to -> MongoClient.connect(“mongodb://localhost:27017/YourDB”, { useNewUrlParser: true }) or your mongoose connection file to -> mongoose.connect(“mongodb://localhost:27017/YourDB”, { useNewUrlParser: true }); Ideally, it’s a version 4 feature, but v3.1.0 and above are supporting it too. Check out MongoDB GitHub … Read more

npm install private github repositories by dependency in package.json

Try this: “dependencies” : { “name1” : “git://github.com/user/project.git#commit-ish”, “name2” : “git://github.com/user/project.git#commit-ish” } You could also try this, where visionmedia/express is name/repo: “dependencies” : { “express” : “visionmedia/express” } Or (if the npm package module exists): “dependencies” : { “name”: “*” } Taken from NPM docs

File uploading with Express 4.0: req.files undefined

The body-parser module only handles JSON and urlencoded form submissions, not multipart (which would be the case if you’re uploading files). For multipart, you’d need to use something like connect-busboy or multer or connect-multiparty (multiparty/formidable is what was originally used in the express bodyParser middleware). Also FWIW, I’m working on an even higher level layer … Read more

Comparing mongoose _id and strings

Mongoose uses the mongodb-native driver, which uses the custom ObjectID type. You can compare ObjectIDs with the .equals() method. With your example, results.userId.equals(AnotherMongoDocument._id). The ObjectID type also has a toString() method, if you wish to store a stringified version of the ObjectID in JSON format, or a cookie. If you use ObjectID = require(“mongodb”).ObjectID (requires … Read more

How to include route handlers in multiple files in Express? [duplicate]

If you want to put the routes in a separate file, for example routes.js, you can create the routes.js file in this way: module.exports = function(app){ app.get(‘/login’, function(req, res){ res.render(‘login’, { title: ‘Express Login’ }); }); //other routes.. } And then you can require it from app.js passing the app object in this way: require(‘./routes’)(app); … Read more

Node.js – Find home directory in platform agnostic way

As mentioned in a more recent answer, the preferred way is now simply: const homedir = require(‘os’).homedir(); [Original Answer] Why not use the USERPROFILE environment variable on win32? function getUserHome() { return process.env[(process.platform == ‘win32’) ? ‘USERPROFILE’ : ‘HOME’]; }

nvm is not compatible with the npm config “prefix” option:

Delete and Reset the prefix $ npm config delete prefix $ npm config set prefix $NVM_DIR/versions/node/v6.11.1 Note: Change the version number with the one indicated in the error message. nvm is not compatible with the npm config “prefix” option: currently set to “/usr/local” Run “npm config delete prefix” or “nvm use –delete-prefix v6.11.1 –silent” to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)