gradle-node-plugin icon indicating copy to clipboard operation
gradle-node-plugin copied to clipboard

Wrong npm version is picked up by Intellij IDE

Open lhtrang opened this issue 5 years ago • 4 comments

I'm working on Gradle project with Intellij IDE and having wrong npm version pickup issue when I try to set npm version outside of node folder in this IDE. (example test-node-plugin.zip)

I have node & npm version specify in build.gradle.

node {
	version = '10.16.0'
	npmVersion = '6.10.0'
}

So there will be 2 dedicated folders for nodejs & npm are generated inside .gradle folder, after I run npmSetup task. (see next screenshot)

By default IDE will pick both nodejs & npm version in nodejs folder (npm version is 6.9.0) image

When I try to pick new version from outside folder (version 6.10.0 in .gradle folder) it still keeping version from nodejs folder, which is 6.9.0. image

Do you have any suggestion on this? Would it make sense to update npm version in nodejs folder, let say I will do npm install [email protected] -g and don't need to refer to npm(outside) folder? IDEA team already close this issue as won't fix because they expect IDE has same behavior as terminal https://youtrack.jetbrains.com/issue/WEB-40017#focus=streamItem-27-3584381.0-0

lhtrang avatar May 21 '20 07:05 lhtrang

@lhtrang sorry for the delay to answer your question. I have to say that I don't know what to think about that.

I haven't been contributing to this project for a long time. I assume that there is a good reason to install npm in a separate directory and not in the Node.js one, but I don't know what it is.

Do you know which command is executed by IDEA to detect the npm version when you add a specific one?

bsautel avatar May 31 '20 08:05 bsautel

Hi @bsautel, thanks for responding. There are some updates in Intellij IDE ticket https://youtrack.jetbrains.com/issue/WEB-40017#focus=streamItem-27-4169014.0-0 so I would like to wait until they have final decision. It might be Intellij IDE issue only when we have distributed NPM. About Node base plugin, it works fine because it prepends NPM PATH (Intellij IDE doesn't, they also mention it on the link). I also did that test on my side.

lhtrang avatar Jun 03 '20 04:06 lhtrang

I kind of agree that when NPM is installed both in the Node.js distribution and also in a separate place as an other version, it is kind of a waste of space. I see no good reason to treat the Node.js distribution as read only. That is not what happens practically, as people do npm install -g npm@latest a lot.

Could it be an up-to-date state invalidation that causes the trouble? It might be useful to check the history of the plugin to find some clues.

rkrisztian avatar Jun 03 '20 08:06 rkrisztian