Unable to install graphql-koa library in my project - node.js

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?

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 run node-dev version 4.0.0 major js file?

I try to run last 2 years node.js express.js project file
its node-dev version is 4.0.0
When I run node-dev index.js
it show error (Module not found)
how can upgrade this project dependencies and how can run
Please help me
I am new to node.js
here is package.json
"name": "m",
"version": "1.0.0",
"description": "Marketing",
"main": "index.js",
"scripts": {
"start": "node-dev index.js"
},
"author": "ibEz",
"license": "ISC",
"dependencies": {
"Faker": "^0.7.2",
"bcrypt": "^3.0.6",
"cookie-parser": "^1.4.4",
"cors": "^2.8.5",
"dotenv": "^8.1.0",
"ejs": "^2.7.1",
"express": "^4.17.1",
"faker": "^4.1.0",
"jsonwebtoken": "^8.5.1",
"moment": "^2.24.0",
"mongoose": "^5.6.13",
"mongoose-data-seed": "^2.1.3",
"node-dev": "^4.0.0",
"node-input-validator": "^4.0.1",
"saslprep": "^1.0.3",
"validation-error": "^1.0.0"
},
"devDependencies": {
"http": "0.0.0"
},
"mdSeed": {
"seedersFolder": "./database/seeds"
}
I solved by delete old package.json files and reinsatll all dependencies
Solved problem by myself.

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

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"

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