I want to run the npm command 'npm audit fix --force', because I already ran 'npm audit fix' and there are still vulnerabilities, is there a way I can somehow fix all the vulnerabilities without breaking my program, I tried running the command in a cloned file to see what damage it would cause, and you guessed it, it broke.
Is there a way I can somehow modify the package.json and package-lock.json to fix this?
Here is my package (making a login and registration system via mongodb)
{
"name": "passport-local-register-login",
"version": "2.0.0",
"description": "Node.js authentication with Passport",
"main": "app.js",
"scripts": {
"start": "node app.js",
"dev": "nodemon app.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"connect-flash": "^0.1.1",
"ejs": "^2.6.1",
"express": "^4.16.4",
"express-ejs-layouts": "^2.5.0",
"express-session": "^1.15.6",
"mongoose": "^5.7.5",
"passport": "^0.4.0",
"passport-local": "^1.0.0"
},
"devDependencies": {
"nodemon": "^1.18.9"
}
}
Related
After having everything working on my Heroku app for months, I started getting this error yesterday:
no pg_hba.conf entry for host "x.x.x.x", user "xxxxx", database "xxxxz", SSL off"
I've only been working on the client side and haven't changed anything on the server, so I don't know what could be going on.
server package.json
{
"name": "spiral-server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha --require test/setup.js",
"dev": "nodemon src/server.js",
"start": "node src/server.js",
"migrate": "postgrator --config postgrator-config.js",
"migrate:test": "env NODE_ENV=test npm run migrate",
"migrate:production": "env SSL=true DATABASE_URL=$(heroku config:get DATABASE_URL) npm run migrate",
"predeploy": "npm audit",
"deploy": "git push heroku master",
"postdeploy": "npm run migrate:production"
},
"keywords": [],
"engines": {
"node": "12.14.1"
},
"author": "",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"helmet": "^4.1.0",
"jsonwebtoken": "^8.5.1",
"knex": "^0.21.5",
"morgan": "^1.10.0",
"pg": "^8.3.3",
"postgrator": "^4.0.1",
"postgrator-cli": "^3.2.0",
"xss": "^1.0.8"
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^8.1.1",
"nodemon": "^2.0.4",
"supertest": "^4.0.2"
}
}
I'm not sure how to start debugging, when I already had it working perfectly.
The only change I might have made was to the GitHub repo name (I changed a few repo names, and not sure if I changed this one or not)
All my other work has been on the client which is a React app hosted on Vercel.
I get the pg error when I query from localhost, Vercel, or Postman.
Any suggestions?
Try the following.
Add a new PGSSLMODE env variable with require as value under your app settings in Heroku.
Then restart your dyno...
heroku ps:restart
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?
I have a project that is using express for the backend API. The project is working on my local machine but when I try to deploy it on a linux VM I get the error "Cannot find module 'Express'".
The steps I took to produce this error were cloning and cding into the repo, and running npm install. express is listed as a dependency in the package.json file. I tried explicitly running npm install express and npm install -g express and both said that they added and/or updated packages and did not return any errors. I also looked in the node_modules folder and there is an express folder there as well.
My package.json:
{
"name": "user-backend",
"version": "1.0.0",
"private": true,
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev-start": "nodemon server.js",
"nvm-start": "nvm use 8.11.3",
"postnvm-start": "nodemon server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.18.0",
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.3",
"cors": "^2.8.4",
"dotenv": "^6.0.0",
"express": "^4.16.3",
"faker": "^4.1.0",
"helmet": "^3.12.1",
"jsonwebtoken": "^8.3.0",
"mongoose": "^5.2.2",
"morgan": "^1.9.0",
"request": "^2.88.0",
"slugify": "^1.3.1",
"validator": "^10.4.0"
},
"devDependencies": {
"nodemon": "^1.18.1"
}
}
Any help would be greatly appreciated. Thank you
This ended up being a simple syntax error in my import ("Express" vs "express")
To clarify the issue:
I have built a node server, which works fine. But on pushing to git and cloning elsewhere, it doesn't work in the new location.
Cleared node_modules, and tried npm install.
gitignore has only node_modules directory in it.
package.json contains the following
{
"name": "node-todo-api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node server/server.js",
"test": "export NODE_ENV=test || SET NODE_ENV=test && mocha server/**/*.test.js",
"test-watch": "nodemon --exec 'npm test'"
},
"engines": {
"node": "6.2.2"
},
"author": "",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.15.2",
"express": "^4.14.0",
"jsonwebtoken": "^8.3.0",
"lodash": "^4.15.0",
"mongodb": "^2.2.5",
"mongoose": "^4.5.9",
"validator": "^5.6.0"
},
"devDependencies": {
"expect": "^1.20.2",
"mocha": "^5.2.0",
"nodemon": "^1.10.2",
"supertest": "^3.1.0"
}
}
I'm getting the error heroku cannot find module 'Sequelize' when the server runs npm start on index.js file. When I run it locally by command heroku local it works fine. What I don't understand is that there is no module called 'Sequelize' in my project. It's called in lower case sequelize. Here's my package.json
{
"name": "anonbay",
"version": "1.0.0",
"description": "social network app",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"author": "saud",
"license": "ISC",
"dependencies": {
"bcrypt-nodejs": "0.0.3",
"body-parser": "^1.16.0",
"express": "^4.14.0",
"express-graphql": "^0.6.3",
"express-session": "^1.15.3",
"graphql": "^0.9.1",
"graphql-subscriptions": "^0.3.1",
"lodash": "^4.17.4",
"mongoose": "^4.7.7",
"pg": "^6.1.2",
"pg-hstore": "^2.3.2",
"sequelize": "^3.30.4",
"subscriptions-transport-ws": "^0.6.0"
}
}
My bad I was importing 'Sequelize' with uppercase. It works locally but it seems heroku is case sensitive. Changed it to 'sequelize' and it worked