npm ERR! Error: EPERM, chmod

10,249

Solution 1

I had similar error and calling:

npm cache clean

Helped me solve it.

Solution 2

npm is telling you that you lack the permissions to modify permissions on the affected file. This is probably a race condition, several of which were fixed in the [email protected] codebase. I will guess that the reason you see it on one disk and not the other is that the disks have different latency and read access times, causing non-reproducible behavior.

You should upgrade to the current version of npm (and node, for that matter). If you are using a Debian-based distribution, you can follow the instructions here < https://github.com/nodesource/distributions#usage-instructions >

curl -sL https://deb.nodesource.com/setup | sudo bash - sudo apt-get install -y nodejs nodejs-legacy sudo npm -g install npm@latest

If that doesn't fix your problem, please let me know; for a quicker response, create an issue on the npm tracker https://github.com/npm/npm/issues and tag me ( @smikes ) in the issue.

Share:
10,249

Related videos on Youtube

Stephan
Author by

Stephan

Updated on June 04, 2022

Comments

  • Stephan
    Stephan almost 2 years

    If have some problems using npm on my raspberry pi when trying to build a node.js application on an usb device.

    package.json looks like this:

    {
      "name" : "node-todo",
      "version" : "1.0.0",
      "description" : "TodoApp",
      "main" : "server.js",
      "autho" : "Stephan",
      "dependencies" : {
         "express" : "*"
      }
    }
    

    Using npm install results in:

    npm WARN package.json [email protected] No repository field.
    npm WARN package.json [email protected] No README data
    npm http GET https://registry.npmjs.org/express
    npm http 304 https://registry.npmjs.org/express
    npm ERR! Error: EPERM, chmod '/media/ServerHD/testraum/test/node_modules/express/package.json'
    npm ERR!  { [Error: EPERM, chmod '/media/ServerHD/testraum/test/node_modules/express/package.json']
    npm ERR!   errno: 50,
    npm ERR!   code: 'EPERM',
    npm ERR!   path: '/media/ServerHD/testraum/test/node_modules/express/package.json',
    npm ERR!   fstream_finish_call: 'chmod',
    npm ERR!   fstream_type: 'File',
    npm ERR!   fstream_path: '/media/ServerHD/testraum/test/node_modules/express/package.json',
    npm ERR!   fstream_class: 'FileWriter',
    npm ERR!   fstream_stack:
    npm ERR!    [ '/opt/node/lib/node_modules/npm/node_modules/fstream/lib/writer.js:305:19',
    npm ERR!      'Object.oncomplete (fs.js:107:15)' ] }
    npm ERR!
    npm ERR! Please try running this command again as root/Administrator.
    
    npm ERR! System Linux 3.12.28+
    npm ERR! command "/opt/node/bin/node" "/opt/node/bin/npm" "install" "-no-bin-links"
    npm ERR! cwd /media/ServerHD/testraum/test
    npm ERR! node -v v0.10.28
    npm ERR! npm -v 1.4.9
    npm ERR! path /media/ServerHD/testraum/test/node_modules/express/package.json
    npm ERR! fstream_path /media/ServerHD/testraum/test/node_modules/express/package.json
    npm ERR! fstream_type File
    npm ERR! fstream_class FileWriter
    npm ERR! fstream_finish_call chmod
    npm ERR! code EPERM
    npm ERR! errno 50
    npm ERR! stack Error: EPERM, chmod '/media/ServerHD/testraum/test/node_modules/express/package.json'
    npm ERR! fstream_stack /opt/node/lib/node_modules/npm/node_modules/fstream/lib/writer.js:305:19
    npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
    npm ERR!
    npm ERR! Additional logging details can be found in:
    npm ERR!     /media/ServerHD/testraum/test/npm-debug.log
    npm ERR! not ok code 0
    

    If i try to run npm install in /home/myUser/Appfolder everything works fine. All files on the ServerHD are created by the same user the homefolder belongs to. I tried using:

    1. npm install -no-bin-links which results in the same problems
    2. trying to change the folder on ServerHD to 777 has no effects for npm
    3. trying to run npm install with sudo

    Using express-generator causes simular problems.

    Hope someone can help. Thanks so far.

    • Salem
      Salem over 9 years
      What partition type is in ServerHD? NTFS/FAT32?
    • Stephan
      Stephan over 9 years
      It's a Fat32 partition, also used via Samba.
  • Stephan
    Stephan over 9 years
    I use node / npm on an arm device, so i think the version i use is the newest for this architecture.
  • Sam Mikes
    Sam Mikes over 9 years
    Nodesource offers an armhf version - ARMv7 and up.. so I think you can't use it on a raspberry pi. Then please just update your npm, since I don't know enough about different-architecture versions of the node binary. (npm is js-only)