[BUG] npx appears to be broken in latest release
Since the latest GA release, most attempts to use npm in Windows are broken. cross-env and npx both no longer work properly and cannot find any of the commands. Both previously worked for cross-platform execution of things like husky and jest. This means our commit hooks are also now broken in Windows.
Current Behavior:
Since the GA release of npx 7.5.2, we cannot execute commands on Windows CLI. npm scripts that previously worked like npx and cross-env no longer function. Commit hooks like husky-run are non-functional.
Where previously working, we now get messages like:
> npx jest --coverage
'jest' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code 1
npm ERR! path C:\Code\nl\node-graphql-utils
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c jest --coverage
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Local\npm-cache\_logs\2021-02-02T23_50_01_621Z-debug.log
npm ERR! code 1
npm ERR! path C:\Code\nl\node-graphql-utils
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c npx jest --coverage
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Local\npm-cache\_logs\2021-02-02T23_50_01_653Z-debug.log
and
> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --amend --no-edit
'husky-run' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code 1
npm ERR! path C:\Code\nl\node-graphql-utils
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c husky-run pre-commit
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Local\npm-cache\_logs\2021-02-03T03_35_51_503Z-debug.log
Expected Behavior:
Core features should work as with v6 unless documented as a breaking change. Documentation also says npx it should prompt to install a package if it doesn't exist.
Steps To Reproduce:
npm install -g npm@latestnpm install jest --save-devin projectnpm install husky --save-devin project- Confirm both are installed with
npm ls jestandnpm ls husky - Attempt
npx jest - Attempt a git commit on Windows
Environment:
- OS: Windows 10 10.0.19042
- Node: 14.15.4
- npm: 7.5.2
I've found that, for reasons unknown, this breaks selectively for directories on Windows NTFS where case-sensitivity has been enabled. If case-sensitivity is disabled on node_modules/.bin it works fine. If case sensitivity is enabled on node_modules/.bin it breaks execution of cmd.
attempting to run rollup without installed globally no longer works. same with browser-sync
'browser-sync' is not recognized as an internal or external command
Environment: OS: Windows 10 1909 Node: 15.8 npm: 7.5.2
Edit: strange. I rolled npm down to 6.14.11. Did npm i in my project and I was able to run rollup and browser-sync. I then installed npm@latest (7.5.3), did npm i again and it seems to be working.
I had done npm i and deleted node_modules before to make sure this wasn't an issue before commenting.
@robross0606 team just tried to repo with latest, are there any other steps or configuration you can provide to confirm this is still a problem?
I don't know. I've abandoned npm v7 completely for now due to trove of bugs and other issues. It was simply unusable.
@darcyclarke I know how to represent this issue. Basically, just like @robross0606 said, I find the same issue in my local Windows PC with the case-sensitive enabled folders.
Environment: OS: Windows 10 20H2 19042.985 Node: 14.16.0/12.16.2 npm: 6.14.11/6.14.4
Steps:
- Create a simple npm workspace
mkdir sample
cd sample
npm init -y
npm install --save-dev typescript
npx tsc -v
you will see the expected vesult: 'Version 4.2.4'
- Create another simple npm workspace
mkdir sample2
cd sample2
Now, open the git bash in administrator, and enable the case sensitive in the folder sample2:
fsutil.exe file setCaseSensitiveInfo .
Then, finish the test in sample2 folder.
npm init -y
npm install --save-dev typescript
npx tsc -v
You will find the npx will not find the ./node_modules/.bin/tsc command, and show messages like below:
npx: 1 安装成功,用时 3.014 秒
This is not the tsc command you are looking for
To get access to the TypeScript compiler, tsc, from the command line either:
- Use npm install typescript to first add TypeScript to your project before using npx
- Use yarn to avoid accidentally running code from packages which haven't been installed
This means npm/npx cannot work on the case sensitive enabled NTFS filesystem.
PS: Just ignore the Chinese chars. I come from China.
Environment
OS: Windows 10 Pro 19044.1387 Node: 17.1.0 NPM: 8.1.4
The current workaround is to select a case-sensitive parent directory and recursively disable CaseSensitiveInfo for all directories.
$path = "";
Get-ChildItem $path -Directory -Recurse | ForEach-Object { fsutil file setCaseSensitiveInfo $_ disable }
This is not explicitly dependent on Powershell, so it can be adapted to other terminals.