NPM in Windows not installing module or adding to package.json - node.js

I have no idea why I get an error for mongoskin. I used this module before but I got rid of it. I removed the node_modules directory then did a fresh npm install, fine everything installs. Then I tried to add a new module minimist as seen below:
C:\www\instantynode\src>npm install minimist --save
npm WARN package.json instanty#0.1.1 No description
npm WARN package.json instanty#0.1.1 No repository field.
npm WARN package.json instanty#0.1.1 No README data
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "minimist" "--save"
npm ERR! node v4.4.0
npm ERR! npm v2.14.20
npm ERR! code EPEERINVALID
npm ERR! peerinvalid The package mongodb#2.1.4 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer mongoskin#1.4.13 wants mongodb#~1.4
npm ERR! Please include the following file with any support request:
npm ERR! C:\www\instantynode\src\npm-debug.log
package.json:
{
"name": "app",
"version": "0.1.1",
"description": "",
"dependencies": {
"bunyan": "1.5.1",
"co": "4.6.0",
"cookie-parser": "^1.4.0",
"forever": "^0.15.1",
"fs": "0.0.2",
"geoip-lite": "^1.1.6",
"handlebars": "^4.0.5",
"jsonwebtoken": "^5.4.1",
"jwt-simple": "^0.4.0",
"koa": "^1.1.2",
"koa-better-ratelimit": "^2.1.2",
"koa-bodyparser": "^2.0.1",
"koa-conditional-get": "^1.0.3",
"koa-generic-session": "^1.10.0",
"koa-handlebars": "^0.5.7",
"koa-mount": "^1.3.0",
"koa-multer": "1.0.0",
"koa-passport": "^2.0.1",
"koa-redis": "^1.0.1",
"koa-router": "^5.3.0",
"koa-static": "^1.5.2",
"lodash": "^3.10.1",
"mongodb": "2.1.4",
"nodemailer": "2.1.0",
"nodemon": "^1.8.1",
"passport": "^0.3.2",
"passport-http-bearer": "^1.0.1",
"passport-local": "^1.0.0",
"socket.io": "^1.3.7",
"socketio-jwt": "^4.3.3"
},
"devDependencies": {
"assert": "1.3.0",
"del": "2.1.0",
"gulp": "^3.9.1",
"gulp-autoprefixer": "3.1.0",
"gulp-concat": "2.6.0",
"gulp-concat-css": "2.2.0",
"gulp-imagemin": "2.4.0",
"gulp-less": "3.0.5",
"gulp-minify-css": "1.2.2",
"gulp-notify": "2.2.0",
"gulp-uglify": "1.5.1",
"imagemin-pngquant": "4.2.0",
"jsdoc": "3.4.0",
"node-inspector": "0.12.5",
"run-sequence": "1.1.5"
},
"main": "app.js",
"scripts": {
"startfn": "forever start -c \"nodemon --harmony\" app.js --exitcrash",
"startf": "forever start -c \"node --harmony\" app.js",
"start": "node --harmony app.js"
},
"author": "",
"license": "ISC"
}
npm install minimist --save does not work as you can see, does not install or add itself to the package.json file. And it is still mentioning mongoskin?
I have a feeling that the NPM in Windows is buggy?

i think that mongoskin only work with mongodb driver older than 1.4. You might have installed mongoskin in global mode, try to remove it.

You are trying to install minimist, which has its own package.json with its own dependencies. In these it says that it wants mongoskin to be installed, which has a dependency on mongodb itself, but in another version than you have it (you have 2.1.4 but as the error says, it needs ~1.4).
So, because you provided the --save parameter, you want npm to respect these dependencies and do not install mongodb in the desired version on top of it.

Ok I've found the issue. The NPM in Windows is way more sensitive than the one in Linux. In Linux I can manually remove the line from the package.json file and just remove the node_modules directory. However in Windows it appears to be cached by NPM, so I had to manually use the npm remove mongoskin --save command.
When I did this so that the package.json looked like it should I was able to install minimist via npm install minimist --save without issues!
I'm not surprised Windows... Not surprised...

In your package.json, try to change this:
"mongodb": "2.1.4",
to this:
"mongodb": "1.4.*",

Related

After removing node_modules folder and later running npm isntall throws error

For a fresh installation, I have removed the node_modules folder using the command rm -rf node_modules/.Then from the terminal I have run npm install in Ubuntu, but now i am getting below error, could someone please advise on what steps should I follow to fix this issue ?
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: #badeball/cypress-cucumber-preprocessor#11.4.0
npm ERR! Found: esbuild#0.15.10
npm ERR! node_modules/esbuild
npm ERR! dev esbuild#"^0.15.10" from the root project
npm ERR! peer esbuild#"*" from #bahmutov/cypress-esbuild-preprocessor#2.1.5
npm ERR! node_modules/#bahmutov/cypress-esbuild-preprocessor
npm ERR! dev #bahmutov/cypress-esbuild-preprocessor#"^2.1.5" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional esbuild#"^0.14.23" from #badeball/cypress-cucumber-preprocessor#11.4.0
npm ERR! node_modules/#badeball/cypress-cucumber-preprocessor
npm ERR! #badeball/cypress-cucumber-preprocessor#"^11.4.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: esbuild#0.14.54
npm ERR! node_modules/esbuild
npm ERR! peerOptional esbuild#"^0.14.23" from #badeball/cypress-cucumber-preprocessor#11.4.0
npm ERR! node_modules/#badeball/cypress-cucumber-preprocessor
npm ERR! #badeball/cypress-cucumber-preprocessor#"^11.4.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /home/den/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/den/.npm/_logs/2022-10-15T03_40_29_742Z-debug-0.log
// package.json
{
"name": "booktest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://someurl.com"
},
"author": "BookTest",
"license": "UNLICENSED",
"private": true,
"scripts": {
"remove-files": "node removeFiles.js",
"cucumber-report": "node createreport.js",
"cypress:open": "cypress open",
"cy:simpro-run": "cypress run && npm run cucumber-report",
"cy:rest-api": "cypress run --headless --spec tests/cypress/integration/restapi/**/*.spec.js"
},
"devDependencies": {
"#babel/core": "^7.13.8",
"#babel/polyfill": "^7.12.1",
"#babel/preset-env": "^7.13.9",
"#bahmutov/cypress-esbuild-preprocessor": "^2.1.5",
"cheerio": "^1.0.0-rc.5",
"cucumber-html-reporter": "^5.3.0",
"cypress": "^10.10.0",
"cypress-dotenv": "^1.2.2",
"cypress-file-upload": "^4.1.1",
"cypress-localstorage-commands": "^1.4.1",
"cypress-wait-until": "^1.7.1",
"esbuild": "^0.15.10",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.22.0",
"fs-extra": "^8.1.0",
"gulp": "^4.0.2",
"gulp-autoprefixer": "^7.0.1",
"gulp-babel": "^8.0.0",
"gulp-concat": "^2.6.1",
"gulp-debug": "^4.0.0",
"gulp-eslint": "^6.0.0",
"gulp-filter": "^6.0.0",
"gulp-fs-cache": "^0.1.0",
"gulp-iconfont": "^10.0.3",
"gulp-if": "^3.0.0",
"gulp-livereload": "^4.0.2",
"gulp-order": "^1.2.0",
"gulp-sass": "^4.1.0",
"gulp-sourcemaps": "^2.6.5",
"gulp-terser": "^1.4.1",
"gulp-wait": "0.0.2",
"lazypipe": "^1.0.2",
"merge-stream": "^2.0.0",
"node-sass": "^4.14.1"
},
"browserslist": [
"last 2 Chrome versions",
"last 2 Firefox versions",
"last 2 Safari versions",
"last 2 Edge versions",
"IE 11",
"last 2 ChromeAndroid versions",
"last 2 iOS versions",
"last 2 Samsung versions",
"last 2 FirefoxAndroid versions"
],
"dependencies": {
"#badeball/cypress-cucumber-preprocessor": "^11.4.0",
"#cypress/webpack-preprocessor": "^5.14.0",
"auth0-js": "^9.14.3",
"dotenv": "^8.2.0",
"idb": "^6.0.0",
"moment": "^2.29.1",
"papaparse": "^5.3.0",
"path": "^0.12.7",
"pdf-parse": "^1.1.1",
"pdfjs-dist": "^2.6.347"
}
}
The problem looks like a mis-match of versions, although I couldn't reproduce the same error message.
If you download the #badeball/cypress-cucumber-preprocessor repository file, unzip it and copy the example folder that most closely matches your current setup - looks like /esbuild-cjs is the closest.
If you use that folder as the project root (rename it whatever you want) and npm install to set up node-modules, then look in the node-module folder you will see these versions have been installed.
"cypress": "10.10.0",
"#badeball/cypress-cucumber-preprocessor": "#13.0.2",
"#bahmutov/cypress-esbuild-preprocessor": "#2.1.5"
"esbuild": '0.14.54',
which is fairly close to the recommendation in the error message.
The package.json just has
{
"devDependencies": {
"#badeball/cypress-cucumber-preprocessor": "latest",
"#bahmutov/cypress-esbuild-preprocessor": "latest",
"cypress": "latest"
}
}
If you want you can change latest to the specific versions, and add the other packages you need,
but don't add the entry for esbuild because it's correct version is already being installed by #badeball/cypress-cucumber-preprocessor.
Any additions you make to dependencies or devDependencies, you will need to run npm install to update node-modules.

React/React Native dependency issues

I've been working on a react native app, and I keep running into dependency issues. I finally ironed out my dependencies so that I can actually npm install. Now I am trying to add react-native-image-mapper, and while our app is using react 17, react-native-image-mapper wants react 16.8.3. I tried using that react version, but then all the rest of my dependencies were off. I was reading that react 17 was a "gradual" upgrade from 16, so I tried to npm i --force, but then my app would not run at all.
Here are the dependencies from package.json:
"#react-navigation/bottom-tabs": "^6.0.8",
"#react-navigation/native": "^6.0.4",
"#react-navigation/native-stack": "^6.2.2",
"#use-expo/font": "^2.0.0",
"axios": "^0.21.1",
"cloudinary": "^1.27.1",
"cors": "^2.8.5",
"dotenv": "^10.0.0",
"expo": "~42.0.1",
"expo-app-loading": "1.1.2",
"expo-camera": "^11.2.2",
"expo-font": "~9.2.1",
"expo-status-bar": "~1.0.4",
"express": "^4.17.1",
"firebase": "8.2.3",
"firebase-admin": "^9.12.0",
"morgan": "^1.9.1",
"pg": "^8.5.1",
"react": "17.0.1",
"react-native": "0.64.2",
"react-native-keyboard-aware-scroll-view": "^0.9.4",
"react-native-safe-area-context": "3.2.0",
"react-native-screens": "^3.4.0",
"react-native-select-dropdown": "^1.2.0",
"react-native-web": "^0.17.5",
"react-redux": "^7.2.4",
"redux": "^4.1.0",
"redux-devtools-extension": "^2.13.9",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"sequelize": "^6.3.5",
"uuid": "^8.3.2"
},
"devDependencies": {
"#babel/core": "^7.12.10",
"#babel/preset-react": "^7.12.10",
"#babel/register": "^7.12.10",
"babel-loader": "^8.2.2",
"eslint": "^7.32.0",
"eslint-plugin-react": "^7.26.1",
"esm": "^3.2.25",
"nodemon": "^1.19.4",
"react-dom": "17.0.1"
}
Here is the error message I get when I try to add react-native-image-mapper:
npm ERR!
npm ERR! While resolving: mole-tracks#0.0.1
npm ERR! Found: react#17.0.1
npm ERR! node_modules/react
npm ERR! react#"17.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"16.8.3" from react-native-image-mapper#0.1.11
npm ERR! node_modules/react-native-image-mapper
npm ERR! react-native-image-mapper#"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
Is there any simple way to untangle problematic dependencies? Is there something glaringly wrong with our dependencies as they stand?
I'm looking for practical advice on how to solve this specific problem as well as tips for avoiding this kind of thing in the future.
Try to use this command
npm install --legacy-peer-deps
I looked at the react-native-image-mapper library and I can say that its structure is poor as a library therefore it gives you the error. If you want to use it anyway, I suggest you just copy the source code (which is only 1 page) and add it to your project as a component.
There is no need to install it because there are no native parts that exist in the code. Only JavaScript.

Locally installed NPM module commands can't be found

For any scripts that are set up in my package.json file for modules installed locally, npm says it cannot find the command.
Below is my package.json. I have already run an ‘npm install` without any issues installing the packages.
{
"name": "app",
"private": true,
"dependencies": {
"#babel/core": "^7.8.6",
"#babel/preset-env": "^7.8.6",
"#babel/preset-react": "^7.8.3",
"babel-loader": "^8.0.6",
"bootstrap": "^4.4.1",
"jquery": "^1.9.1",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-owl-carousel": "^2.3.1",
"react-redux": "^7.2.0",
"react-router-dom": "^5.1.2",
"react-slick": "^0.25.2",
"reactstrap": "^8.4.1",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"slick-carousel": "^1.8.1",
"webpack-cli": "^3.3.11"
},
"scripts": {
"postinstall": "webpack",
"start": "webpack --watch --mode=development"
},
"engines": {
"node": "10.13.0",
"npm": "6.4.1"
},
"devDependencies": {
"css-loader": "^3.4.2",
"style-loader": "^1.1.3",
"webpack": "^4.42.0"
}
}
When I try to run npm start from the root file, I get these errors:
sh: webpack: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! app# start: `webpack --watch --mode=development`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the app# start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I have this same problem across multiple projects. If I install globally it will work, but from what I understand with webpack, that should not be necessary and is discouraged: https://webpack.js.org/guides/installation/#global-installation.
Any ideas what the trouble may be here? Thanks!
The issue was the directory my app was located in had a / in the directory name (e.g. a/b > app > node_modules). The / is interpreted as a : and npm doesn't like that.

node app fails to run on mojave: ReferenceError: internalBinding is not defined

I've tried to unsuccessfully run a node app, which runs fine on both High Sierra and Windows 10, but fails on Mojave 10.14.1.
This is the error shown when running the gulp build_dev task:
[23:44:42] Requiring external module babel-register
fs.js:25
'use strict';
^
ReferenceError: internalBinding is not defined
at fs.js:25:1
at req_ (/Users/user1/Documents/NodeProjects/myapp/node_modules/natives/index.js:137:5)
at Object.req [as require] (/Users/user1/Documents/NodeProjects/myapp/node_modules/natives/index.js:54:10)
at Object.<anonymous> (/Users/user1/Documents/NodeProjects/myapp/node_modules/vinyl-fs/node_modules/graceful-fs/fs.js:1:37)
at Module._compile (internal/modules/cjs/loader.js:707:30)
at Module._extensions..js (internal/modules/cjs/loader.js:718:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/user1/Documents/NodeProjects/myapp/node_modules/babel-register/lib/node.js:152:7)
at Module.load (internal/modules/cjs/loader.js:605:32)
at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
at Function.Module._load (internal/modules/cjs/loader.js:536:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myapp#1.0.0 dev: `node node_modules/gulp/bin/gulp.js build_dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myapp#1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/user1/.npm/_logs/2018-11-04T22_44_42_709Z-debug.log
This is the content of the package.json file with all the dependencies used in the application:
{
"name": "myapp",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test-dev": "node node_modules/gulp/bin/gulp.js test_dev",
"test-prod": "node node_modules/gulp/bin/gulp.js test_prod",
"dev": "node node_modules/gulp/bin/gulp.js build_dev",
"prod": "node node_modules/gulp/bin/gulp.js build_prod"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel-polyfill": "^6.26.0",
"body-parser": "^1.17.2",
"cookie-parser": "^1.4.3",
"envify": "^4.1.0",
"express": "^4.16.2",
"glob": "^7.1.2",
"http-status-codes": "^1.1.6",
"morgan": "^1.8.2",
"multi-glob": "^1.0.1",
"npm": "^6.4.1",
"path": "^0.12.7"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-core": "^6.26.0",
"babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-preset-env": "^1.6.0",
"babel-register": "^6.24.1",
"babelify": "^7.3.0",
"browser-sync": "^2.26.3",
"browserify": "^16.1.0",
"gulp": "^3.9.1",
"gulp-concat": "^2.6.1",
"gulp-if": "^2.0.2",
"gulp-imagemin": "^3.3.0",
"gulp-minify-css": "^1.2.4",
"gulp-nodemon": "^2.2.1",
"gulp-notify": "^3.0.0",
"gulp-rename": "^1.2.2",
"gulp-sass": "^3.1.0",
"gulp-sass-glob": "^1.0.8",
"gulp-sourcemaps": "^2.6.0",
"gulp-uglify": "^3.0.0",
"gulp-util": "^3.0.8",
"imagemin-pngquant": "^5.0.1",
"run-sequence": "^2.2.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
}
}
Any hint on how to debug this problem? Could be related to gcc compiler version?
node version: 11.1.0
npm version: 6.4.1
At this link I've uploaded the log of the "npm install" command to install dependencies: npm_install.log
Try updating natives to the latest version. This commit seems to resolve the issue you're having.
I downgraded Node version from 10.15.0(LTS) to 10.10.0. And this fixed internalBinding error for me.
sudo npm cache clean -f
sudo npm install -g n
sudo n 10.10.0
In my case, the issue was with the node_modules installation, so do the following.
Perform a yarn audit
Check if you have any critical vulnerabilities
Either upgrade the version of the module or search for an alternative module.
yarn install
You should be good to go
Note: Issue was not with the node version in my case it was just a vulnerable module(gulp-angular-templatecache). I also suggest you do npm upgrade and npm rebuild if the above method doesn't work.
npm audit doesn't work with private repositories but yarn audit does.

npm ERR! version not found: i#0.3.2 error

Please help. I am having a NPM app which when I downloaded locally and trying to do a "npm install" is throwing me the - "npm ERR! version not found: i#0.3.2" error.
C:\Users\xyaz\Desktop\MS\MSWeb\WebContent>npm install
npm WARN package.json msportal#0.0.1-SNAPSHOT No description
npm WARN package.json msportal#0.0.1-SNAPSHOT No repository field.
npm WARN package.json msportal#0.0.1-SNAPSHOT No README data
npm WARN package.json msportal#0.0.1-SNAPSHOT No license field.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! version not found: i#0.3.2
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\xyaz\Desktop\MS\MSWeb\WebContent\npm-debug.log
I tried googling and was able to find this solution
https://github.com/pksunkara/inflect/issues/11
but I am not sure how to apply that solution to my problem.
I mean, I dont see a reference to "i" anywhere in my package.json or I am not able to recognize something that is very obviously present.
Here is my package.json file
{
"author": "QSD",
"name": "msportal",
"homepage": "http://www.cqst.com",
"version": "0.0.1-SNAPSHOT",
"buildversion": "0.1",
"distdirroot": "release",
"distdirextension": "src/content",
"engines": {
"node": ">= 0.8.4"
},
"dependencies": {},
"devDependencies": {
"fs-extra": "^0.16.3",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-compress": "~0.9.1",
"grunt-contrib-concat": "~0.4.0",
"grunt-contrib-connect": "~0.8.0",
"grunt-contrib-copy": "~0.4.0",
"grunt-contrib-cssmin": "~0.4.1",
"grunt-contrib-htmlmin": "~0.2.0",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-less": "~0.11.0",
"grunt-contrib-uglify": "~0.5.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-execute": "~0.2.1",
"grunt-html2js": "~0.2.7",
"grunt-include-source": "~0.3.5",
"grunt-text-replace": "~0.3.11",
"http-server": "^0.6.1",
"json-proxy": "~0.1.2",
"livereloadx": "^0.3.2",
"load-grunt-tasks": "^1.0.0",
"time-grunt": "^1.0.0",
"underscore": "~1.6.0",
"webserver": "~1.1.2"
},
"scripts": {
"prestart": "npm install",
"start": "http-server -a localhost -p 8000 -c-1"
}
}
I tried doing "npm install -g npm". But, that doesnt help either.
Any inputs on how to fix this?
i#0.3.2 got unpublished, so anything depending on it will need to be upgraded to use i#0.3.3, which was published almost immediately after 0.3.2 got unpublished.
npm ls i
will show you the path to it (and show you that it's MISSING), as well as what depends on it
Update: After editing the package.json to use
"json-proxy":"*"
you should no longer get this error.
If you're curious the dependency chain looks like this. json-proxy depends on
optimist/ httpp-proxy/utile/i

Resources