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

Fix sandboxed-module not working when using npx #70

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

tie
Copy link

@tie tie commented May 1, 2020

This PR fixes originPath being a URL instead of a path.

The requireLike(…).resolve function accepts a path, but CallSite.getFileName(…) returns a URI with file:// scheme. This commit fixes the issue by removing the prefix if origin path starts with file scheme.

Since module path resolution looks for node_modules in all directories of $PWD, the issue does not arise during development. However, scripts started by npx that depend on sandboxed-module package would break with MODULE_NOT_FOUND error.

tie added 5 commits May 1, 2020 14:10
The requireLike(…).resolve function accepts a path, but CallSite.getFileName(…)
returns a URI with file:// scheme. This commit fixes the issue by removing the
prefix if origin path starts with file scheme.

Since module resolution looks for node_modules in all directories of $PWD,
the issue does not arise during development. However, commands that depend on
sandboxed-module package would break with MODULE_NOT_FOUND when using npx.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant