Multer module won't start
Solution 1
You have to install the module locally, without the -g
flag:
$ npm i multer
Alternatively, you can either link the globally installed module to local directory or specify an environment variable NODE_PATH
as illustrated in NodeJS require a global module/package
Solution 2
If using typescript don't forget to install it's types
npm install @types/multer
Jason
I'm a full-stack developer working professionally on C#, WinForms, and WCF. In my own time, I work mainly with open source and web technologies. I also enjoy video games, tabletop RPGs, homebrewing, DIY, gardening, and more.
Updated on August 01, 2022Comments
-
Jason over 1 year
I'm writing a web app using the MEAN stack. I installed multer via npm like so:
sudo npm install -g multer
and I require it in one of my routes files:
var multer = require("multer");
I'm using
nodemon
and it throws the following error every time it restarts since I've added the require statement.28 Feb 18:39:13 - [nodemon] restarting due to changes... 28 Feb 18:39:13 - [nodemon] starting `node ./bin/www` module.js:338 throw err; ^ Error: Cannot find module 'multer' at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:278:25) at Module.require (module.js:365:17) at require (module.js:384:17) at Object.<anonymous> (/Users/jason/Desktop/Node/todoApp/routes/todos.js:8:14) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) 28 Feb 18:39:13 - [nodemon] app crashed - waiting for file changes before starting...
I've installed mongo, node, and express all in the past two days. I'm running OS X Yosemite version 10.10.2.