From 2f651b2d64523bdd377d22b8b7213a04ad82f459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 2 May 2023 02:35:33 +0200 Subject: fix(npm): canonicalize filename before returning (#18948) This commit changes how paths for npm packages are handled, by canonicalizing them when resolving. This is done so that instead of returning "node_modules/@/node_modules//index.js" (which is a symlink) we "node_modules/@/index.js. Fixes https://github.com/denoland/deno/issues/18924 Fixes https://github.com/bluwy/create-vite-extra/issues/31 --------- Co-authored-by: David Sherret --- cli/npm/resolvers/local.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'cli/npm') diff --git a/cli/npm/resolvers/local.rs b/cli/npm/resolvers/local.rs index f5385c2f1..b4cf5af27 100644 --- a/cli/npm/resolvers/local.rs +++ b/cli/npm/resolvers/local.rs @@ -91,7 +91,11 @@ impl LocalNpmPackageResolver { specifier: &ModuleSpecifier, ) -> Result { match self.maybe_resolve_folder_for_specifier(specifier) { - Some(path) => Ok(path), + // Canonicalize the path so it's not pointing to the symlinked directory + // in `node_modules` directory of the referrer. + Some(path) => { + Ok(deno_core::strip_unc_prefix(self.fs.canonicalize(&path)?)) + } None => bail!("could not find npm package for '{}'", specifier), } } -- cgit v1.2.3