![](/img/trans.png)
[英]ENOENT: no such file or directory, open './config/secrets.json'
[英]Error: ENOENT: no such file or directory, open '../config.json'
嘗試使用以下代碼在 nodejs 中為 AWS SES 加載外部配置文件。
aws.config.loadFromPath('../config.json');
它拋出這個錯誤
Error: ENOENT: no such file or directory, open '../config.json'
現在文件在那個位置,但上面的代碼沒有看到它。
請問有什么快速解決辦法嗎?
更新
它發生在本地和服務器上。
使用__dirname
let AWS = require('aws-sdk')
const path = require('path')
const dirPath = path.join(__dirname, '/config.json')
AWS.config.loadFromPath(dirPath)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.