Changes to package-lock.json causes eslint to be not found

Description

 We hit an interesting issue where when we update the package-lock.json file the eslint command fails. (Example:  https://app.circleci.com/pipelines/github/OpenNMS/opennms/25182/workflows/520c6cb7-70fe-47bd-ac2e-58de4137ad62/jobs/195003)

After a bit of investigation, I found that the issue might be with NPM cache going out of sync. 

To resolve the issue on my own brach, I made this modification:

 

In opennms/core/web-assets/ci.js add the following lines after line 33 `{_}console.info('node_modules is potentially out of date compared to package-lock.json');{_}`
 

const cache_cleanup_child = child_process.execFile(path.join(__dirname, 'target', 'node', 'npm'), ['cache', 'clean', '--force']); cache_cleanup_child.stdout.pipe(process.stdout); cache_cleanup_child.stderr.pipe(process.stderr);

Acceptance / Success Criteria

None

Lucidchart Diagrams

Activity

Show:

Benjamin Reed November 7, 2022 at 4:23 PM

I ended up just removing the webpack-bundle-analyzer from the build in 2022 and up. It's not currently used (it only gets uncommented while working on dependency optimization) anyway.

Benjamin Reed November 7, 2022 at 3:37 PM

eslint was a red herring, the problem was a bundle analyzer mismatch:

[INFO] npm ERR! code ETARGET [INFO] npm ERR! notarget No matching version found for webpack-bundle-analyzer@4.7.0. [INFO] npm ERR! notarget In most cases you or one of your dependencies are requesting [INFO] npm ERR! notarget a package version that doesn't exist.

This was probably introduced by a dependabot merge and has nothing to do with eslint, it just happens to be the next thing run.

The changes introduced just mean that npm is going to do more work downloading than it needs to.

Morteza October 28, 2022 at 2:26 PM

Does it make sense to flush the cache when `package-lock.json` is out of sync (or has been updated)?

 

This issue came up when was working on https://opennms.atlassian.net/browse/NMS-14903#icft=NMS-14903.

Fixed

Details

Assignee

Reporter

Sprint

Priority

PagerDuty

Created October 28, 2022 at 2:24 PM
Updated November 7, 2022 at 4:23 PM
Resolved November 7, 2022 at 4:23 PM

Flag notifications