node.js - Nodejs express 上传文件debian vps报错

标签 node.js linux multer

我正在尝试将文件上传到 nodejs 服务器。 我使用 multer。

const multer  = require('multer'); const UPLOAD_PATH = 'uploads'; 
const upload = multer({ dest: `${UPLOAD_PATH}/` }); 
const sericesApi=(app)=> {
     app.post('/api/upload', upload.single('avatar'), (req, res) => {
         try {
             res.send({'file':req.file});
         } catch (err) {
             res.sendStatus(400);
         }
    }); }
module.exports = sericesApi;

在我的本地主机 (Ubuntu 16.04) 上一切正常,但在 VPS - Debian GNU/Linux 8.7 (jessie) 上我得到 ERR_CONNECTION_REFUSED 或 ERR_EMPTY_RESPONSE。 我试过使用:multer、busboy、express-fileupload。都没有用

最佳答案

解决了!!!带有 watch 参数的 pm2 有问题。上传新文件后重新启动应用程序

关于node.js - Nodejs express 上传文件debian vps报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43408039/

相关文章:

javascript - 在不编辑服务器代码的情况下在 node.js 中捕获控制台输出

javascript - Eslint:警告文件默认被忽略。使用否定忽略模式

linux - 根据特定列拆分列

c++ - linux会不会阻止栈和堆互相生长?

javascript - PreventDefault() 方法不阻止页面重新加载 ReactJS

node.js - 使用 multer-s3 nodejs 将图像上传到亚马逊 s3

eclipse - 如何使用 Supervisor 在没有命令提示符的情况下运行 Node js 应用程序(如果我想在 Eclipse 中运行)

mysql - ( Mysql ) 使用带有 Node js 的存储过程插入数据?

java - 执行异常InvocationTargetException : null when executing the tests in Linux/OSX environment using Play Framework Java

node.js - 如何使用multer和NodeJS将图像上传到GCS存储桶?