Error: Cannot find module '/app/build/index.js' - node.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

Related

Not able to install project dependencies NodeJS

I am trying to install dependency in a project but getting this error. I already upgraded all dependencies and versions of npm but that's not working for me.
Package.json:
{
"name": "task",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app"
},
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.1.0",
"body-parser": "^1.19.0",
"connect-mongo": "^3.2.0",
"ejs": "^3.1.6",
"express": "^4.18.1",
"express-fileupload": "^1.4.0",
"express-flash": "^0.0.2",
"express-session": "^1.17.3",
"lodash": "^4.17.21",
"mongodb": "^4.9.1",
"mongoose": "^6.0.5",
"multer": "^1.4.3",
"node": "^16.6.1",
"nodemailer": "^6.7.0",
"nodemon": "^2.0.13",
"open": "^8.4.0",
"passport": "^0.6.0",
"passport-local": "^1.0.0",
"simplebar": "^5.3.5"
}
}

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.

Unable to install graphql-koa library in my project

Whenever I'm trying to install koa yarn add apollo-server-koa graphql, I'm getting this error:
Couldn't find package "#koa/cors#^2.2.1" required by "apollo-server-koa" on the "npm" registry.
I tried npm instead of yarn and I got the same error.
Here is my package.json file:
"name": "onlineshopbe",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"bcrypt": "^5.0.0",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"express-handlebars": "^5.1.0",
"file-url": "^3.0.0",
"graphql": "^15.3.0",
"graphql-relay": "^0.6.0",
"graphql-sequelize": "^9.4.0",
"jsonwebtoken": "^8.5.1",
"koa": "^2.13.0",
"multer": "^1.4.2",
"nodemon": "^2.0.4",
"pg": "^8.3.0",
"sequelize": "^6.3.4"
},
"devDependencies": {},
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js"
},
"author": "",
"license": "ISC"
}
Any suggestions please?

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.

Resources