Skip to content

[BUG] npm link error EPERM #2079

Closed
Closed

Description

@eight04

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

Activity

  1. added
    Bug
    Needs Triage
    Release 7.x
    on Oct 29, 2020
  2. nlf commented on Oct 29, 2020

    @nlf
    Contributor

    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?

  3. eight04 commented on Oct 30, 2020

    @eight04
    Author

    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?

  4. CAM-Gerlach commented on Nov 3, 2020

    @CAM-Gerlach

    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

  5. ljharb commented on Nov 3, 2020

    @ljharb
    Contributor

    @CAM-Gerlach what about npm v7.0.7?

  6. added a commit that references this issue on Nov 6, 2020
    0e58e6f
  7. added this to the OSS - Sprint 19 milestone on Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds TriageRelease 7.x

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions