-
Notifications
You must be signed in to change notification settings - Fork 101
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
Fixed: For making TS notebook in Windows #444
base: main
Are you sure you want to change the base?
Conversation
packages/api/tsserver/tsservers.mts
Outdated
@@ -44,8 +44,9 @@ export class TsServers { | |||
// created, the dependencies are not installed and thus this will | |||
// shut down immediately. Make sure that we handle this case after | |||
// package.json has finished installing its deps. | |||
const child = spawn('npx', ['tsserver'], { | |||
const child = spawn('pnpm', ['dlx' ,'tsserver'], { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to do this, because pnpm
is a dependency for dev, but not for users. This would require our users to have pnpm installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooo okay, I didn't think that way. I will look into this further. Thank you!
This approach ensures portability and compatibility by directly resolving the Key Features of the Solution
Output I hope this solution will be helpful for dev and end user both! |
Documentation for Fixing
spawn npm ENOENT
Error withpnpm dlx
Issue Overview
The error
spawn npm ENOENT
occurred when trying to spawn atsserver
instance usingnpx
in a Node.js script. This error typically happens whennpm
is either missing or not found in the system'sPATH
, which is required fornpx
to function correctly. Althoughnpx
is supposed to work independently, it relies onnpm
being available in the environment. Since the project is usingpnpm
as the package manager, the solution is to usepnpm dlx
instead ofnpx
.Before Resolving the Issue the Error
After Resolving the Issue the Error
How I Resolved the Issue
Replace
npx
withpnpm dlx
:The command that spawns the
tsserver
instance was originally usingnpx
:This was changed to use
pnpm dlx
to make it compatible withpnpm
:The
pnpm dlx
command is similar tonpx
but usespnpm
to run the specified package without requiring global installation. It ensures thatpnpm
is handling the execution, avoiding thespawn npm ENOENT
error.Changes Made to
package.json
No changes were directly made to
package.json
to resolve the error. However, to ensure thatpnpm dlx
can be used smoothly, make sure the following:Added
rimraf
Dependency:Conclusion
By switching from
npx
topnpm dlx
, thespawn npm ENOENT
error was resolved. This solution is optimal for projects usingpnpm
as the package manager, ensuring compatibility and proper execution of thetsserver
without relying onnpm
's presence in the environment.PS: This solution doesn't turn off the server, which was mentioned in the issue, and it also gives the output in my Windows system.
Fix: #297