-
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
[BUG] npm i
tries to recreate root directory (drive letter) in Windows
#6412
Comments
Debug log in the image:
|
That is not the debug log in the image |
🤦♂️ my bad... updated two of the posts Thank you! |
Can confirm. Here is what I got: D:\>npm install express
npm error code EPERM
npm error syscall mkdir
npm error path D:\
npm error errno -4048
npm error Error: EPERM: operation not permitted, mkdir 'D:\'
npm error at async mkdir (node:internal/fs/promises:858:10)
npm error at async Arborist.reify (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:126:7)
npm error at async Install.exec (C:\Program Files\nodejs\node_modules\npm\lib\commands\install.js:150:5)
npm error at async Npm.exec (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:207:9)
npm error at async module.exports (C:\Program Files\nodejs\node_modules\npm\lib\cli\entry.js:74:5) {
npm error errno: -4048,
npm error code: 'EPERM',
npm error syscall: 'mkdir',
npm error path: 'D:\\'
npm error }
npm error
npm error The operation was rejected by your operating system.
npm error It's possible that the file was already in use (by a text editor or antivirus),
npm error or that you lack permissions to access it.
npm error
npm error If you believe this might be a permissions issue, please double-check the
npm error permissions of the file and its containing directories, or try running
npm error the command again as root/Administrator.
npm error A complete log of this run can be found in: C:\Users\Administrator\AppData\Local\npm-cache\_logs\2024-10-29T13_33_55_251Z-debug-0.log In case anyone is wondering, the reason the log file was generated in What might be going on (as far as I can see)Rather than just reporting having the same issue, I have developed a theory as to what may likely be going on here. Below are my thoughts;
My proof to my theoryThe first very important indicator to this happening we see is; npm error Error: EPERM: operation not permitted, mkdir 'D:\' And what happens when we execute this D:\>mkdir "D:/"
Access is denied. (Yes, this happens even when running as Edit to add:Also, if what I believe the issue is really is the issue and the cause of this error, then I believe it should also be worth renaming this GitHub issue to a more descriptive name that reflects the issue's behavior. |
After looking deeper into this, I have finally located the problematic line of code. Below is a code snippet of it and its surrounding code:
// don't create missing dirs on dry runs
if (!this.options.packageLockOnly && !this.options.dryRun) {
// we do NOT want to set ownership on this folder, especially
// recursively, because it can have other side effects to do that
// in a project directory. We just want to make it if it's missing.
await mkdir(resolve(this.path), { recursive: true }) // <------ HERE!
// do not allow the top-level node_modules to be a symlink
await this.#validateNodeModules(resolve(this.path, 'node_modules'))
} My proposal would be to first verify that the directory isn't a "root directory" before attempting to |
node_modules
dir not detected on mounted drives (Windows)npm i
tries to recreate root directory (drive letter) in Windows
Hey! Good catch on the bug, I will change the name but haven't got many ideas, you can suggest something. One side note, using WSL will make a home directory shortcut ~ letter will equal to /home/yourname/
|
Resolution attempt for npm#6412. Unfortunately, resolution of that issue introduces another error; `Tracker "idealTree" already exists`.
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
On Windows when you have a disk partition
(W:\)
specificly reserved for a package it doesn't detect where node_modules are.Expected Behavior
npm install
should install packages as expectedSteps To Reproduce
cd W:\
npm install <any package>
Environment
Note: Computer newly formatted, everything in fresh installation
The text was updated successfully, but these errors were encountered: