1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-26 17:19:06 -05:00

fix(ext/node): fix npm module resolution when --node-modules-dir specified (#17896)

This commit is contained in:
Yoshiya Hinosawa 2023-02-23 22:28:12 +09:00 committed by GitHub
parent 38f9aa0f9c
commit 6de815859b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View file

@ -660,6 +660,13 @@ itest!(deno_run_cowsay {
http_server: true,
});
itest!(deno_run_cowsay_with_node_modules_dir {
args: "run -A --quiet --node-modules-dir npm:cowsay@1.5.0 Hello",
output: "npm/deno_run_cowsay.out",
envs: env_vars_for_npm_tests_no_sync_download(),
http_server: true,
});
itest!(deno_run_cowsay_explicit {
args: "run -A --quiet npm:cowsay@1.5.0/cowsay Hello",
output: "npm/deno_run_cowsay.out",

1
cli/tests/testdata/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
node_modules

View file

@ -371,10 +371,9 @@ Module._findPath = function (request, paths, isMain, parentPath) {
const isRelative = ops.op_require_is_request_relative(
request,
);
const basePath =
(isDenoDirPackage && !isRelative && !usesLocalNodeModulesDir)
? pathResolve(curPath, packageSpecifierSubPath(request))
: pathResolve(curPath, request);
const basePath = (isDenoDirPackage && !isRelative)
? pathResolve(curPath, packageSpecifierSubPath(request))
: pathResolve(curPath, request);
let filename;
const rc = stat(basePath);