Not able to install project dependencies NodeJS - node.js

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"
}
}

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",

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

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?

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 detects changes, says it is restarting but doesn't actually restart

It was working before but it stopped. If I crash the express app in the app.js file, nodemon will restart at first, but once the app.listen() is executed it won't restart. I tried to isolate every element on the app.js file but the behavior continues. I also added some package recently and I deleted them to see if they caused the behavior but it remains.
{
"name": "",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "node app"
},
"author": "",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.2",
"compression": "^1.7.1",
"connect-flash": "^0.1.1",
"cookie-parser": "^1.4.3",
"cookie-session": "^2.0.0-beta.3",
"debug": "^3.1.0",
"ejs": "^2.5.7",
"express": "^4.16.2",
"express-session": "^1.15.6",
"express-validator": "^4.3.0",
"google-finance": "^0.1.10",
"gulp": "^3.9.1",
"mongoose": "^4.13.7",
"morgan": "^1.9.0",
"nodemon": "^1.14.11",
"passport": "^0.4.0",
"passport-facebook": "^2.1.1",
"passport-google-oauth20": "^1.0.0",
"passport-local": "^1.0.0",
"range": "0.0.3",
"round-to": "^2.0.0",
"serve-favicon": "^2.4.5",
"underscore": "^1.8.3"
}
}
Are you sure that you are using nodemon, because the start command should be:
"start": "nodemon app"

Resources