Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running node ps1 script #233

Closed
rotu opened this issue Oct 11, 2023 · 5 comments
Closed

Error when running node ps1 script #233

rotu opened this issue Oct 11, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@rotu
Copy link
Contributor

rotu commented Oct 11, 2023

What version?

0.19.3

Which command?

No response

What happened?

Some scripts fail on proto in Powershell in Windows due to missing node.exe.

E.g. proto run npm -- install esbuild

.\node_modules\.bin\esbuild --version
&: C:\Users\dan\Source\scratch2\node_modules\.bin\esbuild.ps1:24
Line |
  24 |      & "node$exe"  "$basedir/../esbuild/bin/esbuild" $args
     |        ~~~~~~~~~~
     | The term 'node.exe' is not recognized as a name of a cmdlet, function, script file, or executable program. Check
     | the spelling of the name, or if a path was included, verify that the path is correct and try again.

It seems there is a node shim in ~/.proto/bin/node.cmd, which is in my PATH. There is also a bin in C:\Users\dan\.proto\tools\node\20.8.0\node.exe, which is not in my path.

Any logs?

No response

Operating system?

Windows

Architecture?

x64

@rotu rotu added the bug Something isn't working label Oct 11, 2023
@milesj
Copy link
Contributor

milesj commented Oct 11, 2023

I'm assuming the node_modules in this case were installing via npm?

@rotu
Copy link
Contributor Author

rotu commented Oct 12, 2023

I'm assuming the node_modules in this case were installing via npm?

Yep. Here's an example from npm itself:
https://unpkg.com/npm@10.2.0/bin/npm.ps1

I think it would be a good idea for proto (and npm, incidentally) to generate shims which are executables instead of .cmd or .ps1 files. Here are a few good arguments: npm/bin-links#71.

@milesj
Copy link
Contributor

milesj commented Oct 13, 2023

Yeah my initial goal was to generate .exe files on the fly that would basically act like a shim, but I've been unable to get it working yet. That's definitely a future goal.

I have some changes in v0.20 that will help with this issue, but I wouldn't consider it a permanent fix, more of an alternative solution.

@rotu
Copy link
Contributor Author

rotu commented Oct 13, 2023

I’m not sure but I think it might also do to have a custom file extension, add it to the shell’s PATH_EXT, and register proto.exe as a handler for such files.

I don’t think a PowerShell function would work on Windows though - I think npm exec/run-script tend to start new shells with cmd.exe instead.

@milesj
Copy link
Contributor

milesj commented Oct 20, 2023

In v0.20, we now also create bin symlinks, which should help solve these ".exe" use cases.

@milesj milesj closed this as completed Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants