Derek Dunnom
Derek Dunnom

Reputation: 39

force install npm package dependencies doesn't work

My end goal is to install grunt-html-validation and my generic goal is to know how to force npm package dependencies to install. I started down this path because I get high risk errors when I run npm audit which point to qs. When I run npm install request@latest and npm install qs@latest, I get no errors. After doing so, npm list qs does not reflect the expected results, i.e. for qs to be updated to a recent version as the npm audit suggests.

Command#1:

sudo npm install qs

gets:

npm WARN [email protected] requires a peer of grunt@~0.4.1 but none is installed. You must install peer dependencies yourself.
+ [email protected]
added 1 package from 1 contributor, updated 1 package and audited 623 packages in 4.014s
found 19 vulnerabilities (3 low, 10 moderate, 6 high)

Command #2:

sudo npm install request@latest

gets:

+ [email protected]
updated 1 package in 2.584s

Command#3:

npm list qs

gets:

[email protected]
|
[email protected]
|
[email protected] 

Observations/questions in my troubleshooting: - Why won't [email protected] update? It is at the end of the dependency chain. I went deleted @my_project/node_modules/request/node_modules/qs which didn't help. Then I updated @my_project/node_modules/request/package.json/dependencies/qs to ~3.1.0 just to see if it would update results of npm list qs. It did NOT, although @my_project/node_modules/request/node_modules/qs/package.json reflects version 3.1.0 now. I used npm cache clean several times as well - Why didn't Command#1 update [email protected] in my dependency chain?

I am also getting these warnings on npm install grunt-html-validation:

npm WARN deprecated [email protected]: Use uuid module instead
npm WARN deprecated [email protected]: The major version is no longer supported. Please update to 4.x or newer
npm WARN [email protected] requires a peer of grunt@~0.4.1 but none is installed. You must install peer dependencies yourself.

Upvotes: 2

Views: 1011

Answers (2)

vpzomtrrfrt
vpzomtrrfrt

Reputation: 478

[email protected] depends on request@~2.34.0, which means that it will install request version 2.34.x regardless of your root package dependencies.

The best solution is for that dependency to update its dependencies, but for a seemingly abandoned package like this one, you can also try using overrides in your package.json, e.g.:

{
  "dependencies": {
    "grunt-html-validation": "^0.1.18"
  },
  "overrides": {
    "request": "2.88.0"
  }
}

Upvotes: 0

Derek Dunnom
Derek Dunnom

Reputation: 39

Solved: So apparently the problem was that node modules were stored within node modules in my project directory and there were two layers of them like so: grunt-html-validation => request => qs and request => qs

I had to modify the package.json file for BOTH 'request' folders to a version | do npm cache clean and finally the versions updated.

Upvotes: 0

Related Questions