【问题标题】:Multer module won't startMulter 模块无法启动
【发布时间】:2015-05-01 13:40:55
【问题描述】:

我正在使用 MEAN 堆栈编写一个网络应用程序。我通过 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、express全部安装了。我正在运行 OS X Yosemite 版本 10.10.2。

【问题讨论】:

    标签: node.js express mean-stack multer


    【解决方案1】:

    你必须在本地安装模块,没有-g标志:

    $ npm i multer
    

    或者,您可以将全局安装的模块链接到本地​​目录或指定环境变量NODE_PATH,如NodeJS require a global module/package 所示

    【讨论】:

      【解决方案2】:

      如果使用打字稿别忘了安装它的类型

      npm install @types/multer
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-12-01
        • 1970-01-01
        • 2016-06-22
        • 2017-12-11
        • 1970-01-01
        • 1970-01-01
        • 2020-09-05
        • 1970-01-01
        相关资源
        最近更新 更多