[BUG] Path to Node binary not being made correctly in Git Bash
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
Is there an existing issue for this?
- I have searched the existing issues
This issue exists in the latest npm version
- I am using the latest npm
Current Behavior
I encountered this trying to use pnpm after installing it globally so I'll use that as an example. I'd expect it also happens for other scripts calling node in the same way. I believe the issue is npm's because it relates to paths under npm's install directories.
Running pnpm results in the error:
C:\Users\scott\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found
Expected Behavior
pnpm runs because the correct path to node is present.
Steps To Reproduce
Install latest Node via the Windows installer, then:
npm install -g pnpm
pnpm [anything]
I was able to come up with a workaround.
The node script installed at C:\Users\scott\AppData\Roaming\npm\node contains the line:
exec "$basedir/node_modules/node/bin/node" "$@"
That resolves to C:\Users\scott\AppData\Roaming\npm/node_modules/node/bin/node which is a file that contains only "This file intentionally left blank". By simply tacking .exe onto that path in the script, things work again.
Environment
- npm: 9.6.2
- Node.js: v19.8.1
- OS Name: Windows 11 (Microsoft Windows NT 10.0.22621.0 x64)
- System Model Name: n/a, just a PC
npm config:
; "builtin" config from C:\Users\scott\AppData\Roaming\npm\node_modules\npm\npmrc
prefix = "C:\\Users\\scott\\AppData\\Roaming\\npm"
; node bin location = C:\Program Files\nodejs\node.exe
; node version = v19.8.1
; npm local prefix = C:\Users\scott\Projects\Code\project-name
; npm version = 9.6.2
; cwd = C:\Users\scott\Projects\Code\project-name
; HOME = C:\Users\scott
; Run `npm config ls -l` to show all defaults.
I'm running Git Bash inside Windows Terminal. I understand that Git Bash isn't a real Linux but for my very limited needs around installing modules and running code it's always sufficed (I don't want to install and have to work in WSL).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in Git Bash on Windows with the global pnpm install command and inspect the generated node script under C:\Users\scott\AppData\Roaming\npm. Start by tracing how the script builds the node executable path. Done means the generated path selects the executable correctly and pnpm [anything] runs without the shell error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, javascript, node.js
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100