npm link "The file is marked as an executable but could not be run by the operating system."
Asked Answered
M

1

5

So I made a cli with package.json that specifies a bin file.

I npm link'd it. Then I created a new folder on my desktop and npm link foocli which installed it fine to that directory's node_modules folder.

Then I try to run the cli from that dir and it throws:

The file '/usr/local/bin/foocli' is marked as an executable but could not be run by the operating system.

Any idea what's causing this and how I can fix it?

Mailer answered 4/2, 2016 at 0:32 Comment(2)
Do you have #!/usr/bin/env node as the first line of your executable file?Thaliathalidomide
Ah! That was it. I'm an idiot. I had it in there, but went to redo the entire file and erased everything and forgot to add it back. Thanks!Mailer
T
8

#!/usr/bin/env node is needed at the top of the file that is being executed so the shell knows how to execute the file.

Thaliathalidomide answered 4/2, 2016 at 4:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.