Skip to content
This repository has been archived by the owner on Jul 6, 2019. It is now read-only.

Locally installed modules are not used when running with NPX on windows #202

Open
elasti-eitamd opened this issue Jul 10, 2018 · 3 comments

Comments

@elasti-eitamd
Copy link

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.

@danielgary
Copy link

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.

@danielgary
Copy link

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!

@danielgary
Copy link

danielgary commented Dec 6, 2018

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants