502 Bad Gateway (nginx/1.14.0 (Ubuntu)) - node.js

Hi i have a server with multiple subdomain a weird issue started when all domains returned with 502 bad gateway i entered one subdomain and i run npm run dev and it worked but all the remain subdomains still 502, when i go to other subdomain and run npm start the subdomain work while all the other return 502 what should i do.
here's my package for web (on a subdomain)
{
"name": "mmy-route-web",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev -p 8080",
"build": "next build",
"start": "next start"
},
"dependencies": {
"#fortawesome/free-solid-svg-icons": "^5.15.4",
"#fortawesome/react-fontawesome": "^0.1.16",
"#glidejs/glide": "^3.4.0",
"#mailchimp/mailchimp_marketing": "^3.0.43",
"#popperjs/core": "^2.9.2",
"#stripe/stripe-js": "^1.13.2",
"bootstrap": "^5.0.0-beta3",
"cloudinary-build-url": "^0.2.1",
"cloudinary-react": "^1.7.0",
"cookie": "^0.4.1",
"html-react-parser": "^1.2.6",
"lodash": "^4.17.21",
"next": "10.0.9",
"next-iron-session": "^4.1.12",
"nookies": "^2.5.2",
"npm": "^8.1.0",
"parse": "^3.1.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-use-tawk": "^1.0.0",
"sass": "^1.32.8",
"stripe": "^8.145.0",
"styled-components": "^5.2.1",
"swr": "^0.5.5"
},
"browser": {
"child_process": false
}
}
and for my backend (on other subdomain):
{
"name": "parse-server-example",
"version": "1.4.0",
"description": "An example Parse API server using the parse-server module",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/"
},
"license": "MIT",
"dependencies": {
"#parse/fs-files-adapter": "^1.2.0",
"concurrently": "^7.0.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"jimp": "^0.16.1",
"kerberos": "0.0.24",
"nodemailer": "^6.4.17",
"parse": "~1.8.0",
"parse-dashboard": "^2.1.0",
"parse-server": "*",
"parse-server-cloudinary-adapter": "^1.4.0",
"parse-server-dedicated-email-adapter": "^3.0.6",
"parse-server-email-template-adapter": "^1.0.2",
"parse-server-generic-email-adapter": "0.0.4",
"parse-smtp-template": "^2.2.0",
"slugify": "^1.4.6"
},
"scripts": {
"start": "node index.js",
"dev": "concurrently \"cd server && npm run start\" \"npm run start\""
},
"engines": {
"node": ">=4.3"
}
}

Related

Cannot deploy to heroku

Can someone help me regarding this problem. I can run this code by typing npm start but can I run it by any other option like nodemon src/server.js since I want to deploy it to heroku. here is my packag.json
{
"name": "quickstartnodejs",
"version": "1.0.0",
"description": "a quick start for node.js project",
"main": "server.js",
"scripts": {
"start": "nodemon --exec babel-node src/server.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/haryphamhust/quickStartNodeJSProject.git"
},
"keywords": [
"nodejs",
"mysql"
],
"author": "Hary Pham",
"license": "ISC",
"bugs": {
"url": "https://github.com/haryphamhust/quickStartNodeJSProject/issues"
},
"engines": {
"node": "14.15.1"
},
"homepage": "https://github.com/haryphamhust/quickStartNodeJSProject#readme",
"dependencies": {
"absorb": "^1.0.1",
"body-parser": "^1.19.0",
"connect-flash": "^0.1.1",
"cookie-parser": "^1.4.5",
"dotenv": "^8.2.0",
"ejs": "^3.1.2",
"express": "^4.17.1",
"express-fileupload": "^1.2.1",
"express-session": "^1.17.2",
"express-validator": "^6.12.0",
"generate-password": "^1.6.0",
"multer": "^1.4.2",
"mysql": "^2.18.1",
"nodemailer": "^6.6.2",
"passport": "^0.4.1",
"passport-local": "^1.0.0"
},
"devDependencies": {
"#babel/core": "^7.14.8",
"#babel/node": "^7.14.7",
"#babel/preset-env": "^7.14.8",
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"nodemon": "^2.0.3"
}
}
does anyone have an idea
You could try adding a Procfile. Create a new file in your app root directory and call it Procfile (no dots or extentions). Populate it with the following:
web: node ./src/server.js
Check out the docs here:
https://devcenter.heroku.com/articles/getting-started-with-nodejs

npm install how to prevent nested node_mocules folders

I have a package.json file that has
"dependencies": {
"packageA": "^1.0.0",
and this package A has another dependency in his package.json
"dependencies": {
"packageA_B": "^1.0.0",
Then, if I run npm install on windows 10, node v11.11.0 I end up having
/node_modules/packageA
/node_modules/packageA/node_modules/packageA_B
Then, if I delete this package and run npm install packageA I end up having
/node_modules/packageA
/node_modules/packageA_B
Which is what I want from the beginning. Why is this inconsistency happening? How to force to install all packages in a non-nested way?
package.json
{
"name": "first_package",
"private": true,
"description": "",
"main": "gatsby-config.js",
"version": "0.2.25",
"author": "",
"dependencies": {
"packageA": "git+https://blah.git#h5c8f72",
"gatsby": "2.1.4",
"gatsby-plugin-compile-es6-packages": "^1.0.6",
"gatsby-plugin-offline": "^2.0.24",
"gatsby-plugin-page-creator": "^2.0.10",
"gatsby-plugin-react-helmet": "^3.0.8",
"gatsby-plugin-sharp": "^2.0.25",
"gatsby-plugin-styled-components": "^3.0.6",
"gatsby-source-filesystem": "^2.0.23",
"gatsby-transformer-sharp": "^2.1.15",
"path": "0.12.7",
"react": "16.8.6",
"react-dom": "16.8.6",
"styled-components": "^4.1.3",
"styled-icons": "^7.4.2"
},
"devDependencies": {
"babel-eslint": "^10.0",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.1.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-standard": "^4.0.0",
"gulp": "^4.0.0",
"gulp-help": "^1.6.1",
"prettier": "^1.16.4"
},
"keywords": [
""
],
"license": "",
"scripts": {
"build": "gatsby build",
"develop": "gatsby develop",
"start": "npm run develop",
"serve": "gatsby serve",
"test": "echo \"Write tests! -> https://gatsby.app/unit-testing\""
},
"repository": {
"type": "git",
"url": "https://"
},
"bugs": {
"url": "https://"
}
}
Package A package.json
{
"name": "packageA",
"private": true,
"description": "",
"version": "0.2.25",
"main": "index.js",
"author": "",
"dependencies": {
"packageA_B": "0.2.25",
"styled-components": "4.2.0",
"styled-icons": "7.9.0",
"babel-plugin-styled-components": "1.10.0",
"gatsby-plugin-styled-components": "3.0.7",
"gatsby-plugin-page-creator": "2.0.12",
"gatsby-source-filesystem": "2.0.28",
"gatsby-plugin-compile-es6-packages": "1.1.0",
"path": "0.12.7",
"esm": "3.2.14",
"prop-types": "15.7.2",
"gatsby-plugin-gtag": "1.0.10",
"gatsby-plugin-manifest": "2.0.26",
"react-cookie-consent": "2.2.2"
},
"peerDependencies": {
"gatsby": "2.1.4",
"react": "16.8.6",
"react-dom": "16.8.6"
},
"devDependencies": {
"gatsby": "2.1.4",
"react": "16.8.6",
"react-dom": "16.8.6",
"babel-eslint": "^10.0",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.1.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-standard": "^4.0.0",
"gulp": "^4.0.0",
"gulp-help": "^1.6.1",
"prettier": "^1.16.4"
},
"keywords": [
""
],
"license": "",
"scripts": {
"build": "gatsby build",
"develop": "gatsby develop",
"start": "npm run develop",
"serve": "gatsby serve",
"test": "echo \"Write tests! -> https://gatsby.app/unit-testing\""
},
"repository": {
"type": "git",
"url": ""
},
"bugs": {
"url": ""
}
}
Package A_B package.json
{
"name": "packageA_B",
"version": "0.2.25",
"description": "",
"author": "",
"main": "index.js",
"license": "",
"private": false,
"dependencies": {
"styled-components": "4.2.0",
"styled-icons": "7.9.0",
"babel-plugin-styled-components": "1.10.0",
"gatsby-plugin-styled-components": "3.0.7",
"gatsby-plugin-page-creator": "2.0.12",
"gatsby-source-filesystem": "2.0.28",
"gatsby-plugin-compile-es6-packages": "1.1.0",
"path": "0.12.7",
"esm": "3.2.14",
"prop-types": "15.7.2",
"gatsby-mdx": "0.4.2",
"#mdx-js/mdx": "0.20.3",
"#mdx-js/tag": "0.20.3",
"gatsby-image": "2.0.31",
"gatsby-plugin-offline": "2.0.25",
"gatsby-plugin-react-helmet": "3.0.11",
"gatsby-plugin-sharp": "2.0.32",
"gatsby-transformer-sharp": "2.1.17",
"react-helmet": "5.2.0",
"react-share": "2.4.0"
},
"peerDependencies": {
"gatsby": "2.1.4",
"react": "16.8.6",
"react-dom": "16.8.6"
},
"devDependencies": {
"gatsby": "2.1.4",
"react": "16.8.6",
"react-dom": "16.8.6",
"babel-eslint": "^10.0",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.1.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-standard": "^4.0.0",
"gulp": "^4.0.0",
"gulp-help": "^1.6.1",
"prettier": "^1.16.4"
},
"keywords": [
""
],
"scripts": {
"build": "gatsby build",
"develop": "gatsby develop",
"start": "npm run develop",
"serve": "gatsby serve",
"test": "echo \"Write tests! -> https://gatsby.app/unit-testing\""
},
"repository": {
"type": "git",
"url": ""
},
"bugs": {
"url": ""
}
}
Solved by specifying not an exact version "1.0.0" but a compatible version "^1.0.0". Somehow with the exact version npm doesn't share the package even though they are the exact same version. Also, running npm dedupe doesn't make anything when an exact version is specified.

Could not proxy reques

Proxy error: Could not proxy request /api/profile/all from localhost:3000 to http://localhost:5000. [1] See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNRESET)
Hi I was wondering if anyone knows the solution to this problem. The application was working just fine yesterday, but today it started raising this error up. Please I desperately need help. I have to finish this project before the 5th of February.
//package.json(Node)
{
"name": "devconnector",
"version": "1.0.0",
"description": "Social network for developers",
"main": "server.js",
"scripts": {
"client-install": "npm install --prefix client",
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"dev": "concurrently \"npm run client\" \"npm run server\""
},
"author": "Brad Traversy",
"license": "MIT",
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.2",
"concurrently": "^3.5.1",
"express": "^4.16.3",
"gravatar": "^1.6.0",
"jsonwebtoken": "^8.2.0",
"moment": "^2.24.0",
"mongoose": "^5.0.12",
"npm": "^6.5.0",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"validator": "^9.4.1"
},
"devDependencies": {
"nodemon": "^1.17.3"
}
}
//package.json(React)
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"#fortawesome/fontawesome": "^1.1.8",
"#fortawesome/react-fontawesome": "^0.1.3",
"axios": "^0.18.0",
"classnames": "^2.2.5",
"jwt-decode": "^2.2.0",
"moment": "^2.22.0",
"react": "^16.3.1",
"react-dom": "^16.3.1",
"react-html-table-to-excel": "^2.0.0",
"react-moment": "^0.7.0",
"react-redux": "^5.0.7",
"react-router-dom": "^4.2.2",
"react-scripts": "1.1.4",
"react-table": "^6.8.6",
"reactstrap": "^7.0.2",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:5000"
}

heroku app crashes because of missing module, but works on localhost

I have an app that I successfully deployed to heroku, but when I try to access it, I get this screen...
The log says the following...
The error I believe is causing the issue is Error: Cannot find module 'mongoose'.
Here is my package.json for reference...
{
"name": "ovo",
"version": "1.0.0",
"description": "see and sort OVO in real time!",
"main": "server.js",
"scripts": {
"build": "webpack --config webpack.prod.config.js",
"dev": "concurrently -k \"npm run frontend\" \"npm run backend\"",
"frontend": "webpack -d --watch",
"backend": "nodemon server.js",
"start": "npm run build && NODE_ENV=production node server.js",
"test": "mocha --compilers js:babel-core/register ./test/**/*.js --require ignore-styles"
},
"engines": {
"node": "6.11.0",
"npm": "5.0.3"
},
"repository": {
"type": "git",
"url": "git+https://github.com/leojacoby/ovo.git"
},
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.17.1",
"babel-core": "^6.24.1",
"babel-loader": "^6.4.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.0",
"enzyme": "^2.8.1",
"expect": "^1.20.2",
"express": "^4.15.2",
"immutability-helper": "^2.6.5",
"mocha": "^3.2.0",
"mongoose": "^5.4.0",
"node-sass": "^4.5.2",
"prop-types": "^15.6.0",
"rc-slider": "^8.6.0",
"rc-tooltip": "^3.7.0",
"react": "^15.5.4",
"react-addons-update": "^15.6.2",
"react-bootstrap-table": "^4.3.1",
"react-bootstrap-table-next": "^0.1.3",
"react-dom": "^15.5.4",
"react-rangeslider": "^2.2.0",
"react-redux": "^5.0.5",
"redux": "^3.7.2",
"redux-devtools": "^3.4.0",
"redux-devtools-dock-monitor": "^1.1.2",
"redux-devtools-log-monitor": "^1.3.0",
"sass-loader": "^6.0.3",
"style-loader": "^0.16.1",
"webpack": "^2.3.3"
},
"devDependencies": {
"babel-eslint": "^7.2.2",
"concurrently": "^3.5.0",
"eslint": "^3.19.0",
"eslint-loader": "^1.9.0",
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^6.10.3",
"eslint-watch": "^3.1.0",
"ignore-styles": "^5.0.1",
"nodemon": "^1.11.0",
"react-addons-test-utils": "^15.5.1",
"react-test-renderer": "^15.5.4",
"webpack-dev-middleware": "^1.10.1",
"webpack-dev-server": "^2.4.2",
"webpack-hot-middleware": "^2.18.0"
},
"bugs": {
"url": "https://github.com/leojacoby/ovo/issues"
},
"homepage": "https://github.com/leojacoby/ovo#readme",
"directories": {
"test": "test"
},
"keywords": []
}
The 'mongoose' npm package is in my package.json, and everything works just fine when I run it on my localhost. Please let me know if you want any more information and thank you for reading!
Turns out I hadn't connected my github to my heroku. I was pushing to github but it was not updating heroku so I kept experiencing the same errors. This is what I had to enable in heroku and then my edits actually manifested in the heroku.
An alternative is to just type in git push heroku master into the terminal everytime.
The last thing I had to do was type in heroku config:set MONGODB_URI='mongodb://<name>:<password>#ds123050.mlab.com:23050/ovodb' into the terminal for heroku to access my environmental variable.
Are you pushing node_modules in your code? If yes try to delete that folder and let Heroku install all modules all over again.

how to add dependencies to Openshift V3 nodeJs env

I need some help, i'm trying to add mongoose to my openshift v3 env but can't find how.
already try to use package.json.
Edit :
deploy log
package.json
{
"name": "nodejs-ex",
"version": "0.0.1",
"description": "projet",
"main": "server.js",
"dependencies": {
"body-parser": "^1.17.2",
"chai": "^3.5.0",
"chai-http": "^2.0.1",
"ejs": "^2.4.1",
"express": "^4.13.4",
"mocha": "^2.4.5",
"mongodb": "^2.1.16",
"mongoose": "^4.10.3",
"morgan": "^1.7.0",
"object-assign": "4.1.0"
},
"engine": {
"node": "*",
"npm": "*"
},
"scripts": {
"start": "node server.js",
"test": "IP=0.0.0.0 PORT=3030 mocha --timeout 5000 tests/*_test.js"
},
Thanks

Resources