Reputation: 9738
I have mail configuration code in all.js
.
Now i am trying to import this in my mail.js
service, so i imported the config
module as follows :-
mail.js
config = require('config'),
all.js
mailer: {
auth: {
user: "XXXXXXX",
pass: "abc@123"
}
}
Gives me error cannot find module, but the module exists i have checked it.
How to solve this?
Upvotes: 8
Views: 77461
Reputation: 709
so you have to modify the path relative to the file you are using process.env not relative to the specified file config.json
eg:
node_modules
.gitignore
.env
config.json
folder:
file.js
using config.json in file.js process.env.SECRET_KEY
.env: SECRET_KEY=../config.json //because you go out of folder in file.js to get into config.json
Upvotes: 0
Reputation: 404
This also occurs when you don't have the config package installed. You may just need to install the config package
npm i config
Upvotes: 4
Reputation: 9738
I used the following code & it worked :-
config = require('../config/config');
Upvotes: 13