Why does node.js need administrative permissions to access my windows share even though the share's premission is 0777

8,717

The folder is owned by a different user. Only the owner of the folder or root can change the permissions using chmod. Therefore, in my case, sudo is required as my user does not own the folder.

Share:
8,717

Related videos on Youtube

Stanislav Bondar
Author by

Stanislav Bondar

Updated on September 18, 2022

Comments

  • Stanislav Bondar
    Stanislav Bondar over 1 year

    I have Ubuntu 14.04 running as a VMware guest on my Windows 8.1 host.

    I have shared a folder on my Windows Host and it is mounted in the Ubuntu guest on startup using this entry in fstab:

    //myhost/work /work cifs credentials=/home/user/.smbcredentials,noserverino,nounix,uid=user,gid=user,file_mode=0777,dir_mode=0777 0 0
    

    Why is it that when using node in interact with the share, sudo is required?

    For example, if I use npm to install something (npm install --no-bin-links) on the share without sudo, I get a bunch of chmod errors:

    npm ERR! Error: EPERM, chmod '/work/project/src/node_modules/webpack/package.json'
    npm ERR!  { [Error: EPERM, chmod '/work/project/src/node_modules/webpack/package.json']
    npm ERR!   errno: 50,
    npm ERR!   code: 'EPERM',
    npm ERR!   path: '/work/project/src/node_modules/webpack/package.json',
    npm ERR!   fstream_finish_call: 'chmod',
    npm ERR!   fstream_type: 'File',
    npm ERR!   fstream_path: '/work/project/src/node_modules/webpack/package.json',
    npm ERR!   fstream_class: 'FileWriter',
    npm ERR!   fstream_stack: 
    npm ERR!    [ '/usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:308:19',
    npm ERR!      'Object.oncomplete (evalmachine.<anonymous>:107:15)' ] }
    npm ERR! 
    npm ERR! Please try running this command again as root/Administrator.
    
    npm ERR! Please include the following file with any support request:
    npm ERR!     /work/project/src/npm-debug.log
    

    If I install it using sudo npm install --no-bin-links, everything works fine.

    The same problem occurs when I use gulp to watch and build my project: gulp watch results in the same chmod errors when building, but sudo gulp watch works fine.

    Since the share is set to 0777, everyone is able to read and write to it. Why is it that I need to use sudo on node scripts?