为什么我的代码上没有快速强大工作的例子呢?

时间:2016-10-13 08:52:28

标签: node.js express formidable

我试图使用这个模块:

https://www.npmjs.com/package/express-formidable

但是当我启动我的app终端时返回:

app.use(formidable());
        ^

TypeError: formidable is not a function

为什么?

2 个答案:

答案 0 :(得分:1)

使用formidable

完成安装后,您需要将npm i -S express-formidable添加到您的应用中

从自述文件中复制粘贴

const express = require('express');
const formidable = require('express-formidable');

var app = express();

app.use(formidable());

答案 1 :(得分:0)

我决定重新安装我的应用程序上的模块。 我在package.json上也做了一个干净,所以现在工作正常!

这是我改变的包的两个部分:

旧: "dependencies": { "base64url": "^2.0.0", "body-parser": "1.9.2", "compression": "^1.6.2", "connect": "^3.5.0", "connect-redis": "^3.1.0", "cookie-parser": "^1.4.3", "crypto": "0.0.3", "express": "4.10.1", "express-formidable": "^0.1.3", "express-session": "^1.14.1", "formidable": "^1.0.17", "fs-extra": "^0.30.0", "helmet": "^2.1.3", "jwt-simple": "~0.5.0", "morgan": "1.5.0", "multer": "^1.2.0", "mysql": "^2.9.0", "path": "^0.12.7", "router": "^1.1.4", "time": "^0.11.4" }

和新的:

"dependencies": { "base64url": "^2.0.0", "body-parser": "^1.15.2", "compression": "^1.6.2", "cookie-parser": "^1.4.3", "express": "^4.14.0", "express-formidable": "^1.0.0", "express-session": "^1.14.1", "fs-extra": "^0.30.0", "helmet": "^2.3.0", "morgan": "^1.7.0", "mysql": "^2.11.1" }

可能模块之间存在一些不兼容性......