-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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: allow package installs in drive root directories #7038
Conversation
While it may be a bug - why would you want to do that? |
It isn't so applicable in Linux or macOS since external drives don't have their own individual root directories but I know a few people that have tried working on a JS project on a USB or external drives in Windows and it failed because of the mkdir issue so it would be a lot more helpful for people using Windows. |
Ah, so maybe not for |
No problem :). I only did |
As mentioned in npm/name-from-folder/pull/36 I'm hesitant to go down this path, frankly. I think this is a good restriction and keeps a lot of odd (and maybe even potentially dangerous) setups from happening. |
As mentioned in npm/name-from-folder#36 I can agree that package installs in a macOS or Linux root directory wouldn't make much sense, but there can be some sense for Windows drives (excluding C drive) as if you have an external drive on Windows and you only want to have your JS project on it then you may want to just install the packages in the root directory. I don't use Windows so I haven't had that situation happen to me before but I know of a few people who have tried doing that before and got an npm error. If your issue is only with boot drive root directories, I could make changes to only allow installs in non boot drive directories. Since the behaviour in npm/name-from-folder#36 was incorrect for Right now when installing packages in a root directory npm gives you one of two errors. |
This is a similar problem to what is experience in docker containers, and it is solved by the convention of putting your code in a folder like |
Oh okay, that makes sense. I'll be closing this pull request then. Thanks :) |
What/Why
Previously trying to do
npm install
in a drive's root directory (e.gC:\
orE:\
in Windows or/
in Linux or macOS) would fail. See screenshots:Ubuntu
Windows
This PR allows users to install npm packages in their drive root directories
What does this PR do and why are these changes being made
The change in
workspaces/aborist/lib/aborist/reify.js
's_validatePath
method was made to check if the project directory exists before creating it. Previously if you were runningnpm install
inside of the drive's root directory (in this example, the E drive), mkdir would get called with pathE:/
and it would try to create a directory at the pathE:\\
which is invalid, and so it would fail. In this example, with this PR,E:\
already exists so it is not needed to be created, and thus no directory is tried to be created atE:\\
.2 tests were added to
test/lib/commands/install.js
.The first one only runs on Windows and tests to see that installs in a root directory work by dry running
npm install
inC:\
The second one runs on platforms that are not Windows and tests to see that installs in a root directory work by dry running
npm install
in/