Can't install NPM in cpanel with sharp any version - node.js

I am using sharp to convert images to webp (project developped with angular + nodejs), it works only localy because i have error when i deploy using Cpanel (nodejs apps), i checked with different versions (latest 0.31.1, 0.27.0 and also 0.23.0 ..). I can install sharp if only i remove it from dependencies :
"dependencies": {
"sharp": "^0.27.0"
Have you any idea ?
Thanks.
Here is error :
npm WARN lifecycle The node binary used for scripts is /home/xxx/nodevenv/nodejs_test/10/bin/node but npm is using /opt/alt/alt-nodejs10/root/usr/bin/node itself. Use the --scripts-prepend-node-path option to include the path for the node binary ....
Here is my package.json :
{
"name": "mysqlproject",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"sharp": "^0.27.0",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"file": "^0.2.2",
"material-icons": "^0.6.1",
"multer": "^1.4.4",
"mysql": "^2.18.1",
"node-fetch": "^3.2.3",
"nodemailer": "6.6.3",
"nodemon": "^2.0.7",
"request": "^2.88.2",
"typeface-open-sans": "^1.1.13",
"typeface-roboto": "^1.1.13"
},
"browser": {
"fs": false,
"path": false,
"os": false,
"crypto": false
}
}

Related

Overriding NPM dependency of a dependency in package.json

I'm getting the following error when I try to import mongoose with TypeScript
node_modules/mongoose/node_modules/mongodb/mongodb.d.ts:3309:5 - error TS2416: Property 'end' in type 'GridFSBucketWriteStream' is not assignable to the same property in base type 'Writable'.
Apparently this was fixed in mongodb 4.3.0, but mongoose uses mongodb 4.2.2
How could I force mongoose to use mongodb 4.3.0+ ?
I tried adding
"overrides": {
"mongoose": {
"mongodb": "^4.3.0"
}
},
to package.json but it didn't fix the issue.
Here's my package.json
{
"name": "reports",
"version": "1.0.0",
"type": "module",
"description": "",
"main": "index.js",
"engines": {
"node": "16.x"
},
"jest": {
"setupFiles": [
"<rootDir>/jestTestEnv.js"
]
},
"scripts": {
"test": "jest --watchAll --setupFiles ./jestTestEnv.js",
"dev": "tsc && nodemon -r dotenv/config dist/server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.1",
"cors": "^2.8.5",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"express-jwt": "^6.1.0",
"express-openid-connect": "^2.5.2",
"express-validator": "^6.14.0",
"jwks-rsa": "^2.0.5",
"mongoose": "^6.1.1"
},
"overrides": {
"mongoose": {
"mongodb": "^4.3.0"
}
},
"devDependencies": {
"#types/body-parser": "^1.19.2",
"#types/cors": "^2.8.12",
"#types/express": "^4.17.13",
"#types/express-jwt": "^6.0.4",
"#types/jest": "^27.4.0",
"#types/node": "^17.0.13",
"#types/supertest": "^2.0.11",
"jest": "^27.4.5",
"supertest": "^6.1.6",
"typescript": "^4.5.5"
}
}
Found the solution. There seems to be a bug here with NPM. Deleting both node_modules AND package-lock.json and then doing npm install fixes the issue. Deleting node_modules on its own doesn't fix it.

Cannot find module 'Express'; already installed locally and globally

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

node server.js gives error -> Cannot find module '../wireprotocol/2_4_support'

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

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

behavior differs for npm install and npm install -g

In order to build frontend sources on Windows 7 with gulp.js I have a package.json file with node_modules dependencies defined in it:
{
"name": "custom-repo-name",
"version": "1.0.0",
"description": "",
"main": "gulpfile.js",
"directories": {
"doc": "doc"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"gulp-concat": "^2.5.2",
"gulp-stylus": "^2.0.3",
"gulp-uglify": "^1.2.0",
"rimraf": "^2.3.4"
},
"devDependencies": {
"gulp": "^3.9.0",
"gulp-concat": "^2.5.2",
"gulp-rev": "^4.0.0",
"gulp-stylus": "^2.0.3",
"gulp-uglify": "^1.2.0",
"gulp-watch": "^4.2.4",
"rimraf": "^2.3.4"
}
}
For some reason when I run
npm install
the dependencies are installed locally into .\node_modules folder and gulp command runs properly.
But when I run
npm install -g,
as I can see from the output, a part of dependencies is missing to be installed and running gulp command fails with an error of failed load of dependencies (gulp-uglify.js for instance).
What's wrong?

Resources