Closed saqlain024 closed 1 year ago
Hi @saqlain024 ,
In order to support you I need the rotating-file-stream version you are using and also you share the relevant part of the code. Also, plese format the error as plain text copied from your console.
Thank you
package.json file `:`
{
"name": "codeial",
"version": "1.0.0",
"description": "My all Social Media Web Application",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1",
"sass": "sass --watch assets/scss:assets/css",
"prod_start": "SET NODE_ENV=production & nodemon index.js"
},
"keywords": [
"Social"
],
"author": "saqlain",
"license": "ISC",
"dependencies": {
"connect-flash": "^0.1.1",
"connect-mongo": "^4.6.0",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"crypto": "^1.0.1",
"dotenv": "^16.0.3",
"ejs": "^3.1.8",
"express": "^4.18.2",
"express-ejs-layouts": "^2.5.1",
"express-session": "^1.17.3",
"gulp-cssnano": "^2.1.3",
"gulp-rev": "^9.0.0",
"gulp-sass": "^5.1.0",
"gulp-uglify-es": "^3.0.0",
"jsonwebtoken": "^9.0.0",
"kue": "^0.11.6",
"mongoose": "^6.8.1",
"morgan": "^1.10.0",
"multer": "^1.4.5-lts.1",
"nodemailer": "^6.9.1",
"passport": "^0.6.0",
"passport-google-oauth": "^2.0.0",
"passport-jwt": "^4.0.1",
"passport-local": "^1.0.0",
"rotating-file-stream": "^3.1.0",
"socket.io": "^4.6.1"
},
"devDependencies": {
"gulp": "^4.0.2",
"gulp-imagemin": "^6.2.0",
"sass": "^1.58.3"
}
}
file in which i used
const fs = require('fs');
const rfs = require('rotating-file-stream');
const path = require('path');
const logDirectory = path.join(__dirname, '../production_logs');
fs.existsSync(logDirectory) || fs.mkdirSync(logDirectory);
const accessLogStream = rfs.createStream('access.log', {
interval: '1d',
path: logDirectory
});
const development = {
name: 'development',
asset_path: './assets',
session_cookie_key: 'blahsomething',
db: 'codeial_development',
smtp: {
service: 'gmail',
host: 'smtp.gmail.com',
port: '587',
secure: 'false',
auth: {
user: 'saklainhmd@gmail.com',
pass: 'ehqifyqwtgibxoka'
}
},
google_client_id: "940547004575-o5odqs8vv1prts5a9hg9omfgfvm2bt2t.apps.googleusercontent.com",
google_client_secret: "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",
google_call_back_url: "http://localhost:8000/users/auth/google/callback",
jwt_secret: 'codeial',
morgan: {
mode : 'dev',
options: {stream: accessLogStream }
}
}
const production = {
name: process.env.CODEIAL_ENVIRONMENT,
asset_path: process.env.CODEIAL_ASSET_PATH,
session_cookie_key: process.env.CODEIAL_SESSION_COOKIE_KEY, //website::randomkeygen
db: process.env.CODEIAL_DB,
smtp: {
service: 'gmail',
host: 'smtp.gmail.com',
port: '587',
secure: 'false',
auth: {
user: process.env.CODEIAL_GMAIL_USERNAME,
pass: process.env.CODEIAL_GMAIL_PASSWORD
}
},
google_client_id: process.env.CODEIAL_GOOGLE_CLIENT_ID,
google_client_secret: process.env.CODEIAL_GOOGLE_CLIENT_SECRET,
google_call_back_url: process.env.CODEIAL_GOOGLE_CALL_BACK_URL,
jwt_secret: process.env.CODEIAL_JWT_SECRET,
morgan: {
mode : 'combined',
options: {stream: accessLogStream }
}
}
// module.exports = development;
// module.exports = eval(process.env.NODE_ENV) == undefined ? development : eval(process.env.NODE_ENV);
module.exports = development;
below error i am getting :
Error: Cannot find module 'fs/promises'
Require stack:
- /home/ubuntu/codeial_project/node_modules/rotating-file-stream/dist/cjs/index.js
- /home/ubuntu/codeial_project/config/environment.js
- /home/ubuntu/codeial_project/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/home/ubuntu/codeial_project/node_modules/rotating-file-stream/dist/cjs/index.js:8:20)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/ubuntu/codeial_project/node_modules/rotating-file-stream/dist/cjs/index.js',
'/home/ubuntu/codeial_project/config/environment.js',
'/home/ubuntu/codeial_project/index.js'
]
}
Error: Cannot find module 'fs/promises'
Here is the problem: you are using an old version of Node.js. You should try to use a supported version regardless from this error.
If that helps, feel free to close the issue.
sir could you please tell which version i use.... actually i am in learning phase so don't know much about this ..
when i am doing "node -v" in my local system then it give "v18.12.1"
and on remote system ( actually i am deploying this project on aws while deployment i am getting same error) there while doing "node -v" i am getting "v12.22.9"
Hi @saqlain024 ,
v18 in your local env 👍 v12 in your production env is too old; you should update it to at least v18
ubuntu@ip-172-31-14-85:~/codeial_project$ npm start