Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

UNC path for dependencies in package.json #7669

Closed
CalaxDev opened this issue Mar 18, 2015 · 2 comments
Closed

UNC path for dependencies in package.json #7669

CalaxDev opened this issue Mar 18, 2015 · 2 comments

Comments

@CalaxDev
Copy link

As of now it is possible to use local paths, git-urls and http paths to get and install a package.

But it is not possible to do something like:

"dependencies:{
"myPackage": "file://myRemoteHost/MyPath/myTarball.tgz"
}

because when doing this, on npm install it looks up the gitub repository.

Can this be added as a feature? Or am I simply doing this wrong?

@othiym23
Copy link
Contributor

Local dependencies are a relatively new feature, and there are a few rough edges still, one of which you appear to have found. If there's a fully-qualified URL (i.e. if it's prefixed with file:), npm should never try to resolve that to a GitHub URL. I'd be happy to take a patch for this issue, but I don't really have a good setup for testing it in my work environment (when I'm running Windows, I'm the only one doing so on the team), so a test case as well as instructions on how to run the test case / set up a test environment would also be welcome.

@othiym23
Copy link
Contributor

Upon review, it seems clear to me that what's happening is that a version of npm older than 2.0.0 was used for the original post. The presence of the file: prefix is enough to tell newer versions of npm that they're dealing with a local dependency, and as I said above, should never trigger a GitHub-based install.

As far as adding host / shares to file paths using UNC syntax, that's a little more complicated. Node uses UNC paths for everything internally (that's how Node implements its long path support), and the file: protocol description for URIs does allow for hostnames to be included in the path, but getting all of that mapped properly is a can of worms that is very tricky to address without inadvertently causing breaking changes to how local dependencies work. The safest strategy for dealing with this is the same as for other legacy environments working with network shares on Windows, which is to say mapping the share to a drive letter. Paths with drive letters should work fine in local dependencies.

If someone wants to work on the path-handling code in npm and the packages it uses for dealing with local dependencies, we’d be happy to land that as a patch as long as it didn’t break backwards compatibility. It would also be possible to land as a breaking change, but that’s a lot more delicate, because part of the nature of local dependencies is that the team can’t really see how they’re being used. Since the CLI team isn’t going to have the time to do this work themselves, I’m going to close this feature request, but because we’d be happy to see the change land, I’m going to mark it patch-welcome. Thanks for the problem statement, and thanks for your time!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants