Skip to content

Node 10, npm gives an EPERM on every operation #20112

Description

@paulvanbrenk

Version: v10.0.0-nightly201804175eb9f3c91c
Platform: Windows 10 64-bit and 32-bit
Subsystem: npm

Both node and npm are installed in default location, and on the path.

This works as expected in Node 9, which is why I filed an issue here.

Any npm command results in the following error on several machines:

fs.js:111
    throw err;
    ^

Error: EPERM: operation not permitted, open 'C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js'
    at Object.fs.openSync (fs.js:545:3)
    at Object.fs.readFileSync (fs.js:451:33)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:688:20)
    at Module.load (internal/modules/cjs/loader.js:589:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
    at Function.Module._load (internal/modules/cjs/loader.js:520:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:719:10)
    at startup (internal/bootstrap/node.js:229:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:576:3)
fs.js:111
    throw err;
    ^

Error: EPERM: operation not permitted, open 'C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js'
    at Object.fs.openSync (fs.js:545:3)
    at Object.fs.readFileSync (fs.js:451:33)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:688:20)
    at Module.load (internal/modules/cjs/loader.js:589:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
    at Function.Module._load (internal/modules/cjs/loader.js:520:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:719:10)
    at startup (internal/bootstrap/node.js:229:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:576:3)

Activity

  1. bnoordhuis commented on Apr 17, 2018

    @bnoordhuis
    Member

    EPERM means "permissions issue." Could be a number of things, from an overzealous virus scanner to wrong file permissions.

  2. added
    windowsIssues and PRs related to the Windows platform.
    npmIssues and PRs related to the npm client dependency or the npm registry.
    on Apr 17, 2018
  3. paulvanbrenk commented on Apr 17, 2018

    @paulvanbrenk
    Author

    My guess is wrong file permissions are set by the installer, since Node 9 (both npm 5.6 and 5.8) work as expected. File location doesn't seem to be changed between versions, and this happens consistently on multiple machines, and keeps happening even after an hour.

  4. billti commented on Apr 17, 2018

    @billti
    Contributor

    I can repro the same issue easily. I tried to debug npm, but turns out this is before it even gets to running npm (as can been seen from the stack above, where it's just trying to open the npm-cli.js file to load it).

    I have the latest v10.x branch built locally, and stepping through the code it appears to be due to the recent libuv, which is requesting write access to any opened file. As npm (along with the rest of Node.js) is installed under C:\Program Files, then write access is not granted (unless running with Admin rights).

    You can see the change causing this here: ae2b5bc#diff-4a14951fd12c46802543f3a8aa54a620R437 . If I comment out that exact line ("access |= FILE_WRITE_ATTRIBUTES;") and rebuild, npm runs without issue.

    This seems fundamentally busted on Windows if you can't run npm commands. (Odd/concerning if this has been in the v10.x branch for 15 days without being caught!)

  5. vsemozhetbyt commented on Apr 17, 2018

    @vsemozhetbyt
    Contributor

    cc @nodejs/libuv @nodejs/platform-windows

  6. richardlau commented on Apr 17, 2018

    @richardlau
    Member

    Corresponding libuv PR: libuv/libuv#1777

    cc @bzoz

  7. vsemozhetbyt commented on Apr 17, 2018

    @vsemozhetbyt
    Contributor

    Can reproduce on Windows 7 x64.

    1. Create simple test.js file, then forbid write access via file property dialog (this should not be simple read-only property, but a security permission change).
    2. This file can be run by all current releases from v4 till v9.
    3. Last Nightly and v8-canary give EPERM: operation not permitted.
  8. added this to the 10.0.0 milestone on Apr 17, 2018
  9. added
    confirmed-bugIssues and PRs for confirmed bugs.
    and removed
    questionIssues asking questions about Node.js.
    on Apr 17, 2018
  10. vsemozhetbyt commented on Apr 17, 2018

    @vsemozhetbyt
    Contributor

    cc @jasnell as this can block v10 release.

  11. added
    libuvIssues and PRs related to the libuv dependency or the uv binding.
    on Apr 18, 2018
  12. 13 remaining items

  13. jasnell commented on Apr 18, 2018

    @jasnell
    Member

    Reopening until the libuv update lands here :)

  14. added a commit that references this issue on Aug 7, 2018
  15. added a commit that references this issue on Jul 27, 2026
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

    confirmed-bugIssues and PRs for confirmed bugs.libuvIssues and PRs related to the libuv dependency or the uv binding.npmIssues and PRs related to the npm client dependency or the npm registry.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions