Locally installed modules are not used when running with NPX on windows
elasti-eitamd opened this issue · comments
My team started using @angular-cli and moved to node version 8.11.3 + npm 6.1.0.
They are using MAC, and I am using Windows 10 64 bit.
Inside package.json we have a few scripts to facilitate our workflows :
"scripts": {
"serve": "npx rimraf dist && npx webpack-dev-server --inline --progress --port 3000 --open",
"serve:prod": "npx rimraf dist && npx webpack-dev-server --config config/webpack.prod.js --inline --progress --port 3000 --open",
"build": "npm run build:prod",
"build:prod": "npx rimraf dist && npx webpack --progress --config config/webpack.prod.js",
"build:dev": "npx rimraf dist && npx webpack --debug --progress --config config/webpack.dev.js"
}
The "npx" right before each command is something I added because when I run it without it, it won't find rimraf, and won't find webpack-dev-server etc.....
Example :
$ npm run serve
> webadmin@0.0.0 serve D:\git\elfs-system\eadmin
> rimraf dist && webpack-dev-server --inline --progress --port 3000 --open
'rimraf' is not recognized as an internal or external command,
You can say I don't have rimraf installed.. but... :
$ npm ls --depth=0 | grep rim
+-- rimraf@2.6.2
Also it is declared inside package.json :
"devDependencies": {
...
...
"rimraf": "^2.6.2",
...
...
},
You can also see "npm bin" knows where my local modules are :
$ ls `npm bin` | grep rim
rimraf
$ npm bin
D:\git\elfs-system\eadmin\node_modules\.bin
ls -la | grep node_modules
lrwxrwxrwx 1 Eitam 197121 37 Nov 15 2016 node_modules -> submodules/eadmin-assets/node_modules
When running npx rimraf it will not find the local install and actually install a temp version, causing longer run times for 'npm run serve' - even worse, when trying to run 'npm run build:prod', webpack tries to use webpack-cli, which I don't have installed globally, but I do have it locally, which webpack won't recognize, and now it asks me which webpack-cli I want to install.
I have a feeling that even if I install webpack-cli globally, it is just a matter of time until some other local module is needed but not recognized.
I kind of think this is related to how isexe and which are working (not seeing symbolic links) inside /.bin/...
At this rate I am going to have to give up my Windows 10 laptop which is not something I want to do...
Any help would be much appreciated.
I'm seeing the same issue, also in Windows. In my instance, we have a package we developed called @gatewayapps/cradle. It has a bin command called cradle in it's package.json.
npx cradle output:
command not found: cradle
What is really odd, is this works fine on a second repo in sibling folder. I've done everything I can to find a difference between the two, but so far no luck.
I found something that might be the issue - at least it solved it for me.
At some point recently, I had enabled the new Windows 10 case sensitivity feature for my repo directory. npx was unable to locate any node module installed with case sensitivity turned on. Hope this helps you!
I did trace this down to isexe in the which module not correctly finding executable files due to case sensitivity in windows folders with case sensitivity enabled.
Here is a similar issue in yarn
yarnpkg/yarn#5813
And here's the root cause
npm/node-which#57
And a pull request for which that resolves it but hasn't been merged
npm/node-which#59