使用PM2进行Multer上传文件 [英] Multer upload files with PM2

查看:192
本文介绍了使用PM2进行Multer上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Express应用,正在使用multer上传文件, 问题是,当我使用PM2在生产服务器中运行应用程序时,multer上传文件给了我一个错误:

i have a express app and am using multer to uploads files, the problem is when i running the app in the production server with PM2 the multer upload file gave me an error:

"错误:ENOENT:没有此类文件或目录,请打开"uploads/img.png" 错误(本机)"

"Error: ENOENT: no such file or directory, open 'uploads/img.png' at Error (native)"

但是当我使用"Debug = projectname:* npm start"运行它时,它就可以正常工作.

but when i run it with "Debug=projectname:* npm start" its just work fine.

请注意,我已经创建了具有对任何人读写"权限的上载目录.

note that i already create uploads directory with all the permissions "read and write for anyone".

(对不起我的英语不好)

(sorry for my bad english)

推荐答案

我将尝试猜测问题所在.

I will try to guess the problem.

在您的pm2上,您将不使用 cwd参数,因此您的应用程序以错误的根目录开头.

At your pm2 will you don't use cwd param, so your application starts with wrong root directory.

这篇关于使用PM2进行Multer上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆