Multer模块不会启动

我正在使用MEAN堆栈编写一个Web应用程序。 我通过npm安装了multer,如下所示:

sudo npm install -g multer 

我需要在我的路线文件之一:

 var multer = require("multer"); 

我正在使用nodemon并且每次重新启动时都会引发以下错误,因为我已经添加了require语句。

 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... 

我已经安装了mongo,node,并且在过去两天里都进行了expression。 我正在运行OS X Yosemite版本10.10.2。

您必须在本地安装模块,而不使用-g标志:

 $ npm i multer 

或者,您可以将全局安装的模块链接到本地​​目录,也可以指定环境variablesNODE_PATHNODE_PATH中所示需要全局模块/包