heroku app crashes because of missing module, but works on localhost - node.js

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.

Related

how can i fix this issue 'babel-node' is not recognized as an internal or external command, operable program or batch file.?

I'm working on node.js project. I have created this project by use Babel which was running fine in previous using node system . i have updated node.js version in my system, after that I'm getting error of Bebel-node. Any one can help me how can i solve this issue??b I have installed all bebal.js module.
I'm using code in bebel.rc
{
"plugins": [
"#babel/plugin-transform-runtime"
],
"presets": [
"#babel/env"
],
"ignore": [
"node_modules",
"src/public"
]
}
this is my updated package.json ....
{
"name": "backend-buluckart-hashing.company",
"version": "0.1.0",
"description": "groffers-nepal",
"main": "index.js",
"scripts": {
"start": "nodemon src/index.js --exec babel-node --presets #babel/env",
"build": "babel src -d dist --source-maps inline --copy-files",
"serve": "node dist/index.js",
"sequelize": "sequelize"
},
"keywords": [],
"author": "Ashutosh singh",
"license": "ISC",
"homepage": "",
"nodemonConfig": {
"ignore": [
"src/public/*"
]
},
"devDependencies": {
"#babel/cli": "^7.17.6",
"#babel/core": "^7.17.5",
"#babel/node": "^7.16.8",
"#babel/plugin-transform-runtime": "^7.17.0",
"#babel/preset-env": "^7.16.11",
"nodemon": "^2.0.15"
},
"dependencies": {
"#babel/runtime": "^7.17.2",
"aws-sdk": "^2.700.0",
"babel-upgrade": "^1.0.1",
"bcrypt-nodejs": "0.0.3",
"body-parser": "^1.18.3",
"cookie-parser": "^1.4.3",
"cors": "^2.8.5",
"dateformat": "^3.0.3",
"dotenv": "^8.0.0",
"event-stream": "^4.0.1",
"express": "^4.16.3",
"express-handlebars": "^6.0.2",
"express-sanitizer": "^1.0.5",
"express-session": "^1.15.6",
"helmet": "^3.15.1",
"joi": "^14.3.0",
"joi-date-extensions": "^1.2.0",
"jsonwebtoken": "^8.3.0",
"kue": "^0.11.1",
"mailparser": "^3.4.0",
"moment": "^2.24.0",
"morgan": "^1.9.0",
"multer": "^1.4.1",
"multer-s3": "^2.9.0",
"mysql": "^2.16.0",
"mysql2": "^1.6.4",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"passport-local": "^1.0.0",
"qs": "^6.10.3",
"radis": "^2.0.0",
"razorpay": "^2.0.6",
"react-bootstrap": "^2.1.2",
"read-excel-file": "^5.2.26",
"request": "^2.88.0",
"rotating-file-stream": "^1.4.1",
"sequelize": "^5.21.13",
"sequelize-cli": "^6.4.1",
"speakeasy": "^2.0.0",
"stack-trace": "0.0.10",
"twilio": "^3.72.0"
}
}
"start": "nodemon --exec npx babel-node src/index.js",

Define no proxy but get 'When "proxy" is specified in package.json' error

When I run npm run dev I get an error message:
When "proxy" is specified in package.json it must start with either http:// or https:// , but I don't define any proxy in my package.json. How can this happen and how do I solve it?
package.json
{
"name": "vue-admin-template",
"version": "4.3.0",
"description": "A vue admin template with Element UI & axios & iconfont & permission control & lint",
"author": "Pan <panfree23#gmail.com>",
"license": "MIT",
"scripts": {
"dev": "vue-cli-service serve",
"build:prod": "vue-cli-service build",
"build:stage": "vue-cli-service build --mode staging",
"preview": "node build/index.js --preview",
"lint": "eslint --ext .js,.vue src",
"test:unit": "jest --clearCache && vue-cli-service test:unit",
"test:ci": "npm run lint && npm run test:unit",
"svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml"
},
"dependencies": {
"#gitgraph/js": "^1.3.5",
"#toast-ui/vue-editor": "^2.5.1",
"axios": "0.18.1",
"chart.js": "^2.9.4",
"chartjs-plugin-datalabels": "^0.7.0",
"echarts": "^4.8.0",
"element-ui": "2.13.2",
"element-ui-el-table-draggable": "^1.2.9",
"fuse.js": "^6.4.3",
"jquery": "^3.5.1",
"js-cookie": "2.2.0",
"jwt-simple": "^0.5.6",
"moment": "^2.27.0",
"monaco-editor": "^0.20.0",
"monaco-editor-webpack-plugin": "^1.9.0",
"normalize.css": "7.0.0",
"nprogress": "0.2.0",
"path-to-regexp": "2.4.0",
"socket.io-client": "^4.0.0",
"tui-editor": "1.3.3",
"vue": "2.6.10",
"vue-chartjs": "^3.5.1",
"vue-i18n": "^8.22.1",
"vue-jwt-decode": "^0.1.0",
"vue-router": "3.0.6",
"vue-showdown": "^2.4.1",
"vuedraggable": "2.20.0",
"vuex": "3.1.0",
"wangeditor": "^3.1.1"
},
"devDependencies": {
"#vue/cli-plugin-babel": "3.6.0",
"#vue/cli-plugin-eslint": "^3.9.1",
"#vue/cli-plugin-unit-jest": "3.6.3",
"#vue/cli-service": "3.6.0",
"#vue/test-utils": "1.0.0-beta.29",
"autoprefixer": "^9.5.1",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.0.1",
"babel-jest": "23.6.0",
"chalk": "2.4.2",
"connect": "3.6.6",
"eslint": "5.15.3",
"eslint-plugin-vue": "5.2.2",
"html-webpack-plugin": "3.2.0",
"mockjs": "1.0.1-beta3",
"runjs": "^4.3.2",
"sass": "^1.26.8",
"sass-loader": "^7.1.0",
"script-ext-html-webpack-plugin": "2.1.3",
"serve-static": "^1.13.2",
"svg-sprite-loader": "4.1.3",
"svgo": "1.2.2",
"vue-template-compiler": "2.6.10"
},
"engines": {
"node": ">=8.9",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}
It was in vue.config.js. Setting wrong proxy here will occur the same error message.

Error: Cannot find module '/app/build/index.js'

I am trying to deploy my app to heroku and I get this error:
Error: Cannot find module '/app/build/index.js'
I have followed the suggestions on some previous threads which didn't work out
Please take a look at my Github Repo and review my packgage.json and Procfile. I have been battling this issue for 2 hours
Here is my package.json file
{
"name": "numberplatedetector",
"version": "1.0.0",
"description": "An app that links drivers and car owners",
"main": "build/index.js",
"scripts": {
"heroku-prebuild": "export NPM_CONFIG_PRODUCTION=false; export NODE_ENV=; NPM_CONFIG_PRODUCTION=false NODE_ENV=development npm install --only=dev --dev",
"heroku-postbuild": "export NPM_CONFIG_PRODUCTION=true; export NODE_ENV=production;",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"test": "echo \"Error: no test specified\" && exit 1",
"dev-start": "set NODE_ENV=development && nodemon --exec babel-node src/index.js",
"start": "node --require babel-polyfill ./build/index.js",
"build": "babel src --out-dir build"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#sendgrid/mail": "^6.4.0",
"babel-polyfill": "^6.26.0",
"bcrypt": "^3.0.6",
"body-parser": "^1.19.0",
"cloudinary": "^1.15.0",
"connect-multiparty": "^2.2.0",
"cors": "^2.8.5",
"dotenv": "^8.1.0",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"mongodb": "^3.3.2",
"mongoose": "^5.7.3",
"multer": "^1.4.2",
"passport-facebook": "^3.0.0",
"passport-google-oauth20": "^2.0.0",
"passport-local": "^1.0.0",
"passport-mocked": "^1.4.0",
"socket.io": "^2.2.0",
"swagger-ui-express": "^4.0.7"
},
"devDependencies": {
"#babel/cli": "^7.5.5",
"#babel/core": "^7.5.5",
"#babel/node": "^7.5.5",
"#babel/preset-env": "^7.5.5",
"#babel/register": "^7.5.5",
"babel-eslint": "^10.0.2",
"chai": "^4.2.0",
"chai-http": "^4.3.0",
"coveralls": "^3.0.6",
"eslint": "^5.16.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-import": "^2.18.2",
"mocha": "^6.2.0",
"nodemon": "^1.19.2",
"nyc": "^14.1.1",
"sinon": "^7.4.1"
}
}
and here is the content of my Procfile:
web: node build/index.js

nodemon not refreshing when using typescript

I'm working on an app with NodeJs, express, typescript and nodemon.
But the page is not refreshed when I changed some code in the ts files.
How can I do to compile the ts file in js and refresh the browser with nodemon (or other tool)?
package.json
{
"name": "myapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.17.2",
"debug": "^2.6.8",
"dotenv": "^2.0.0",
"express": "^4.15.3",
"iconv-lite": "^0.4.17",
"inversify": "^4.11.1",
"jsonwebtoken": "^7.4.1",
"mongoose": "^5.0.10",
"morgan": "^1.8.2",
"passport": "^0.3.2",
"passport-jwt": "^2.2.1",
"rxjs": "^5.4.2",
"typescript": "^2.7.2",
"winston": "^2.3.1"
},
"devDependencies": {
"#types/chai": "^4.0.0",
"#types/debug": "0.0.29",
"#types/dotenv": "^2.0.20",
"#types/express": "^4.0.35",
"#types/mocha": "^2.2.41",
"#types/mongoose": "^4.7.15",
"#types/morgan": "^1.7.32",
"#types/node": "^6.0.77",
"#types/passport": "^0.3.3",
"#types/passport-jwt": "^2.0.20",
"chai": "^4.0.2",
"chai-http": "^3.0.0",
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-typescript": "^3.1.7",
"gulp-yaml": "^1.0.1",
"mocha": "^3.4.2",
"mocha-typescript": "^1.1.4"
},
"scripts": {
"start": "gulp build && nodemon dist/index.js",
"build": "gulp build",
"test": "gulp build && mocha -t 30000 dist/**/*.test.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/devslaw/TypeScript-Node.js-REST-example.git"
},
"keywords": [],
"author": "Arthur Arakelyan <arthur#devslaw.com>",
"license": "ISC",
"homepage": "https://github.com/devslaw/TypeScript-Node.js-REST-example#readme"
}
So know, anytime i make a change, I need to stop the server and run npm start again
The problem lies in the fact that your start script is watching dist/index.js. This folder only changes when the code gets recompiled into plain JavaScript. So you will need to watch the TypeScript files instead. The great thing is that you can change nodemon's default behavior. You will need to add ts-node to your package.json as well.
Try setting the script to something like the following:
nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts
You will then want to set up a nodemon.json file with the following also:
{
"watch": ["src"],
"ext": "ts",
"exec": "ts-node ./src/index.ts"
}

Deploy error on Heroku with /app/karma.config.js

I got a React project with node.js, and want to deploy it on Heroku, I connect Heroku with my github repository: https://github.com/yeziyqf/SecureProgramConc
When the project building on Heroku, I got following error:
-----> Running Node.js buildpack tests...
essential-react#0.3.0 test /app
PHANTOMJS_BIN=./node_modules/.bin/phantomjs ./node_modules/karma/bin/karma start karma.config.js
07 03 2018 04:50:38.115:ERROR [config]: File /app/karma.config.js does not exist!
npm ERR! Test failed. See above for more details.
-----> Node.js buildpack tests failed with exit status 1
What is this problem? Locally I don't have this config file but my project works fine, anybody have a clue on it? Thanks!
Here is the package.json file:
{
"name": "essential-react",
"version": "0.3.0",
"description": "A minimal skeleton for building testable React apps using ES6.",
"main": "src/main.jsx",
"scripts": {
"postinstall": "npm run build",
"server": "node server.js",
"build": "webpack -p --config webpack.production.config.js",
"test": "PHANTOMJS_BIN=./node_modules/.bin/phantomjs ./node_modules/karma/bin/karma start karma.conf.js",
"test-cross-browser": "./node_modules/karma/bin/karma start karma.cross-browser.config.js",
"coveralls": "cat coverage/lcov.info | coveralls",
"clean": "rm build/app.js"
},
"repository": {
"type": "git",
"url": "https://github.com/pheuter/essential-react.git"
},
"keywords": [
"skeleton",
"template",
"react",
"quickstart"
],
"author": "Mark Fayngersh",
"license": "MIT",
"bugs": {
"url": "https://github.com/pheuter/essential-react/issues"
},
"homepage": "https://github.com/pheuter/essential-react",
"devDependencies": {
"coveralls": "^2.11.2",
"istanbul": "^0.3.7",
"istanbul-instrumenter-loader": "^0.1.2",
"karma": "^0.13.22",
"karma-coverage": "^0.2.7",
"karma-mocha": "^0.1.10",
"karma-phantomjs-launcher": "^0.1.4",
"karma-sauce-launcher": "^0.2.10",
"karma-sinon-chai": "^0.3.0",
"karma-webpack": "^1.5.0",
"phantomjs": "^1.9.16",
"react-hot-loader": "^1.2.3",
"react-scripts": "0.2.1",
"webpack-dev-server": "^1.7.0"
},
"dependencies": {
"autoprefixer": "^6.0.2",
"babel-core": "^5.4.7",
"babel-loader": "^5.1.3",
"bootstrap": "^3.3.5",
"bootstrap-social": "^4.9.1",
"bundle-loader": "^0.5.4",
"classnames": "^2.2.0",
"css-loader": "^0.28.9",
"express": "^4.12.3",
"extract-text-webpack-plugin": "^0.8.2",
"file-loader": "^0.8.4",
"firebase": "^4.10.0",
"font-awesome": "^4.4.0",
"history": "^1.13.0",
"jquery": "^2.1.4",
"lazy": "^1.0.11",
"less": "^2.5.3",
"less-loader": "^2.2.1",
"normalizr": "^1.1.0",
"nprogress": "^0.2.0",
"postcss-loader": "^0.6.0",
"postcss-nested": "^1.0.0",
"react": "^0.14.9",
"react-addons-css-transition-group": "^0.14.1",
"react-addons-transition-group": "^0.14.2",
"react-addons-update": "^15.3.0",
"react-bootstrap": "^0.27.0",
"react-dom": "^0.14.1",
"react-native-multiple-choice": "0.0.8",
"react-redux": "^5.0.7",
"react-router": "^1.0.0-rc2",
"react-router-redux": "^4.0.8",
"react-select": "^1.2.1",
"redux": "^3.7.2",
"resource-api-utils": "^1.0.0",
"style-loader": "^0.12.3",
"url-loader": "^0.5.6",
"webpack": "^1.12.1"
}
}

Resources