用fs.createReadStream和fs.readFileSync读取文件
但是一旦文件没有找到
就会报错
2020-12-23 16:42:44,082 ERROR 25598 nodejs.ENOENTError: ENOENT: no such file or directory, open '/Users/laiyinan/Desktop/2020114/jpg/UG1NBQF1_1604470696777.jpg' (uncaughtException throw 1 times on pid:25598)
ENOENTError: ENOENT: no such file or directory, open '/Users/laiyinan/Desktop/2020114/jpg/UG1NBQF1_1604470696777.jpg' (uncaughtException throw 1 times on pid:25598)
errno: -2
code: "ENOENT"
syscall: "open"
path: "/Users/laiyinan/Desktop/2020114/jpg/UG1NBQF1_1604470696777.jpg"
name: "ENOENTError"
pid: 25598
hostname: laiyinandeMacBook-Pro.local
报错以后node就会退出 也就是整个后台都崩了
尝试用try catch包住 还是一样
如何处理?
报错的截图:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…