WebStorm prompts to run `npm install` repeatedly

I'm seeing an issue where I update an NPM package to a new minor version and WebStorm doesn't recognize that the new version has been installed, resulting in it prompting me to run `npm install` over and over again.

When I open the package.json file in WebStorm for the package, it shows the old version of the file, with the old version number. But if I open that file outside of WebStorm, it shows the new version. So the problem is that WebStorm's file content caching does not recognized that the file has changed.

According to this comment, "Comparison is done by file size+timestamp and not content." And as of npm@6, the timestamp on the tarballs installed by NPM is now locked to a fixed date (1985-10-26).

So when the only change to the package.json file is a minor version (e.g. 1.1.0 -> 1.2.0), the file size and timestamp remain exactly the same. So WebStorm doesn't recognize that the file has changed and will not reload the contents from disk, even if I explicitly go to the file in the Project window, right-click and choose Reload from Disk.

If I go to the terminal and `touch` the file to just update the timestamp on it, then WebStorm reloads the contents as expected.

0

Hi Travis,

Did you try to manually change the npm version in the package.json to the one you've installed?Also try invalidating your cache. If none of the above work go to your terminal inside Webstorm and type npm -v to see exactly what version you have installed on your project.

0
Avatar
Permanently deleted user

Praduv83 Any of those solutions will solve the problem each time, but we should not have to do this every time we run `npm install`. As I mentioned, I can get it to work each time by simply running `touch` on the file, but this is a workaround, not a solution.

The problem is that the way WebStorm compares the file for changes is no longer adequate in this scenario, and the result is that the `npm install` feature has unexpected behavior (by prompting it to run over and over). And I don't understand why Reload from Disk doesn't work. Shouldn't that dump the cached contents of the file and.....reload from disk?

Perhaps I shouldn't be posting this on the community forum and instead opening a bug with JetBrains...

0

请先登录再写评论。