Fixed: For making TS notebook in Windows#444
Open
aakash-a-dev wants to merge 7 commits intosrcbookdev:mainfrom
Open
Fixed: For making TS notebook in Windows#444aakash-a-dev wants to merge 7 commits intosrcbookdev:mainfrom
aakash-a-dev wants to merge 7 commits intosrcbookdev:mainfrom
Conversation
nichochar
reviewed
Nov 18, 2024
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'], { |
Contributor
There was a problem hiding this comment.
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.
Contributor
Author
There was a problem hiding this comment.
Ooo okay, I didn't think that way. I will look into this further. Thank you!
Contributor
Author
|
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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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