Skip to content
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 link error EPERM #2079

Closed
eight04 opened this issue Oct 29, 2020 · 4 comments
Closed

[BUG] npm link error EPERM #2079

eight04 opened this issue Oct 29, 2020 · 4 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release

Comments

@eight04
Copy link

eight04 commented Oct 29, 2020

Current Behavior:

C:\Users\eight04\dev\wakfu-autobuild>npm link
npm ERR! code EPERM
npm ERR! syscall symlink
npm ERR! path ..\..\..\..\dev\wakfu-autobuild
npm ERR! dest C:\Users\eight04\AppData\Roaming\npm\node_modules\wakfu-autobuild
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, symlink '..\..\..\..\dev\wakfu-autobuild' -> 'C:\Users\eight04\AppData\Roaming\npm\node_modules\wakfu-autobuild'
npm ERR!  [Error: EPERM: operation not permitted, symlink '..\..\..\..\dev\wakfu-autobuild' -> 'C:\Users\eight04\AppData\Roaming\npm\node_modules\wakfu-autobuild'] {
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '..\\..\\..\\..\\dev\\wakfu-autobuild',
npm ERR!   dest: 'C:\\Users\\eight04\\AppData\\Roaming\\npm\\node_modules\\wakfu-autobuild'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\eight04\AppData\Local\npm-cache\_logs\2020-10-29T09_57_33_549Z-debug.log

Expected Behavior:

Shouldn't the path be . instead of ..\..\..\..\dev\wakfu-autobuild? Or at least it should be ..\..\dev\wakfu-autobuild.

Steps To Reproduce:

  • Run npm link in a package.

I have this issue on multiple packages so I guess it's not a package issue. You can find them here:
https://github.com/eight04/sync-version
https://github.com/eight04/wakfu-autobuild

Environment:

  • OS: Windows 10
  • Node: 15.0.1
  • npm: 7.0.3
@eight04 eight04 added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Oct 29, 2020
@nlf
Copy link
Contributor

nlf commented Oct 29, 2020

the logged message is admittedly a little confusing..

what it's trying to do is create a symlink at C:\Users\eight04\AppData\Roaming\npm\node_modules\wakfu-autobuild that points to ..\..\..\..\dev\wakfu-autobuild, which relative to the first path would be C:\Users\eight04\dev\wakfu-autobuild which given the directory noted in your prompt at the top of the above snippet appears to be correct.

can you confirm you're able to write files to the C:\Users\eight04\AppData\Roaming\npm\node_modules directory as your user?

@eight04
Copy link
Author

eight04 commented Oct 30, 2020

can you confirm you're able to write files to the C:\Users\eight04\AppData\Roaming\npm\node_modules directory as your user?

Yes:

C:\Users\eight04\AppData\Roaming\npm\node_modules>echo foo > foo.txt

C:\Users\eight04\AppData\Roaming\npm\node_modules>type foo.txt
foo

According to Google, it seems that only admins can create symbolic links on Windows:
nodejs/node-v0.x-archive#6342 (comment)

With further testing, I found that this throws:

import {symlink} from "fs/promises";
await symlink(
  '..\\..\\..\\..\\dev\\wakfu-autobuild',
  'C:\\Users\\eight04\\AppData\\Roaming\\npm\\node_modules\\wakfu-autobuild',
  'dir'
);

This works:

import {symlink} from "fs/promises";
await symlink(
  '..\\..\\..\\..\\dev\\wakfu-autobuild',
  'C:\\Users\\eight04\\AppData\\Roaming\\npm\\node_modules\\wakfu-autobuild',
  'junction'
);

(Both works if I open cmd as admin)

However, I haven't seen this error until npm@7. Was something changed in the new version?

@CAM-Gerlach
Copy link

Possibly related to #1923 , which I can repro running npm install on a package with a dependency specified as a path in Node 15.0.1, npm 7.0.3 (latest current) but not Node 14.15.0 , npm 6.14.8 (latest LTS) per pre-commit/pre-commit#1681

@ljharb
Copy link
Contributor

ljharb commented Nov 3, 2020

@CAM-Gerlach what about npm v7.0.7?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants