eirslett / frontend-maven-plugin

"Maven-node-grunt-gulp-npm-node-plugin to end all maven-node-grunt-gulp-npm-plugins." A Maven plugin that downloads/installs Node and NPM locally, runs NPM install, Grunt, Gulp and/or Karma.
Apache License 2.0
4.26k stars 872 forks source link

Delete previous node installation before upgrade #1123

Open adangel opened 1 year ago

adangel commented 1 year ago

Summary

When changing the node version from e.g. v14 to v18 with provided npm, then npm fails with the following exception:

TypeError: Class extends value undefined is not a constructor or null
    at Object.<anonymous> (.../node/node_modules/npm/node_modules/fs-minipass/lib/index.js:136:4)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (.../node/node_modules/npm/node_modules/cacache/lib/content/read.js:4:13)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)

The reason is, that the provided npm is left as a mixture of the old provided npm version and the new npm version.

This PR removes the old node installation (including node_modules and npm, npm.cmd, npx, npx.cmd) entirely, so that only the new files for npm are there in the end.

This fixes #994.

Tests and Documentation

I created a new integration test "node-provided-npm-upgrades".