-
Notifications
You must be signed in to change notification settings - Fork 314
Fixed: For making TS notebook in Windows #444
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
base: main
Are you sure you want to change the base?
Conversation
packages/api/tsserver/tsservers.mts
Outdated
| // 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 ENOENTError withpnpm dlxIssue Overview
The error
spawn npm ENOENToccurred when trying to spawn atsserverinstance usingnpxin a Node.js script. This error typically happens whennpmis either missing or not found in the system'sPATH, which is required fornpxto function correctly. Althoughnpxis supposed to work independently, it relies onnpmbeing available in the environment. Since the project is usingpnpmas the package manager, the solution is to usepnpm dlxinstead ofnpx.Before Resolving the Issue the Error
After Resolving the Issue the Error
How I Resolved the Issue
Replace
npxwithpnpm dlx:The command that spawns the
tsserverinstance was originally usingnpx:This was changed to use
pnpm dlxto make it compatible withpnpm:The
pnpm dlxcommand is similar tonpxbut usespnpmto run the specified package without requiring global installation. It ensures thatpnpmis handling the execution, avoiding thespawn npm ENOENTerror.Changes Made to
package.jsonNo changes were directly made to
package.jsonto resolve the error. However, to ensure thatpnpm dlxcan be used smoothly, make sure the following:Added
rimrafDependency:Conclusion
By switching from
npxtopnpm dlx, thespawn npm ENOENTerror was resolved. This solution is optimal for projects usingpnpmas the package manager, ensuring compatibility and proper execution of thetsserverwithout 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