-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
It is a very weird issue. I am not sure if it is entirely related to npm, but it really brings a horrible experience.
- In my project to build a CLI, I execute
npm link
to link my CLI to global, and it works; I usetest-cli create
instead. - Execute
test-cli create
got an inner execution issue, and it is because I forgot to use shebang, and I also added it, then it works. - Everything works fine, so I commit this change to git. Didn't execute
npm unlink
at this time. - After the commit, I retry to execute
test-cli create
, but I have an issue in terminalzsh: permission denied: test-cli create
, or eventest-cli
itself. - I tried to execute
npm-unlink
andnpm-link
, the issue still exists. - I tried to delete
test-cli
in globalnode_modules
and retry 5, the issue still exists. - I tried to use
chmod
or other syntax to add permission on the target file, or even usesudo
, and I am pretty sure the target file has permission to execute, but the issue still exists. - I changed my branch from the current to the master (haven't merged yet), and everything works fine except the shebang issue.
- With 8, I re-checked my commit, there is nothing but only the line I add shebang.
- I also tried to clear the cache but still had the same issue.
- One thing is very strange, in this issue, when I change my codes and retry the
npm link
, it always returns me anup to date
log with a during time. And when I trynpm unlink -g test-cli
, it also returns me anup to date
log. The during time is almost the same around 700ms on this device. - The target file (
cli.js
) can be executed directly by the node the whole time, and that's also a Plan B to keep on working.
So with the upper description, especially 11, I wonder if there are some issues between git, the file system, and npm? When I commit, git locks something but has a side effect on npm, so npm always thinks there is nothing changed and nothing to be done.
I think re-installing the node or deleting my local git repo can help, but I still wondering why. And the repo is for business so I cannot open it or provide any test files. Not sure if this issue only happens on my device.
Expected Behavior
No matter what we did to git, npm link
can always link the current local module, or output some warnings or errors when there are issues in it.
Steps To Reproduce
- Find a project, in my case a CLI.
- Execute
npm link
and check if it can work well by link. - Change some codes and commit them, especially the final file it executes.
- Retry 2.
Don't know if this can happen this issue.
Environment
- npm: 10.2.0
- Node.js: v18.18.1
- OS Name: macOS Ventura 13.3
- System Model Name: Macbook Pro
- npm config:
; "user" config from /SecretPath/.npmrc
///SecretHost//:_auth = (protected)
///SecretHost//:_authToken = (protected)
; always-auth = true ; overridden by project
email = "[email protected]"
; registry = "http:///SecretHost/" ; overridden by project
; "project" config from /SecretPath/Documents/Workplace/test-cli/.npmrc
always-auth = true
fsevents_binary_host_mirror = "https://npm.taobao.org/mirrors/fsevents/"
puppeteer_download_host = "https://npm.taobao.org/mirrors/"
registry = "http:///SecretHost/"
; node bin location = /SecretPath/.nvm/versions/node/v18.18.1/bin/node
; node version = v18.18.1
; npm local prefix = /SecretPath/Documents/Workplace/test-cli
; npm version = 10.2.0
; cwd = /SecretPath/Documents/Workplace/test-cli
; HOME = /Users/Secret
; Run `npm config ls -l` to show all defaults.