cedricium / amo-cli

💻 A CLI tool used for interacting with the Mozilla Addons (AMO)
https://cedric.tech/amo-cli/
MIT License
0 stars 0 forks source link

Windows (?): Permission error when trying to create 'config' directory during postinstall script #13

Open cedricium opened 6 years ago

cedricium commented 6 years ago

Noticed this today on a Windows machine, although, I feel like any non-sudo user may also run into this problem if they do not have the correct permissions:

sudo npm install -g amo-cli
/usr/local/bin/amo -> /usr/local/lib/node_modules/amo-cli/bin/amo

> amo-cli@0.2.2 postinstall /usr/local/lib/node_modules/amo-cli
> node scripts/postinstall.js

fs.js:905
  return binding.mkdir(pathModule.toNamespacedPath(path),
                 ^

Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/amo-cli/config'
    at Object.fs.mkdirSync (fs.js:905:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/amo-cli/scripts/postinstall.js:18:6)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Function.Module.runMain (module.js:701:10)
    at startup (bootstrap_node.js:193:16)
    at bootstrap_node.js:617:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! amo-cli@0.2.2 postinstall: `node scripts/postinstall.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the amo-cli@0.2.2 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/camaya/.npm/_logs/2018-05-15T20_13_44_633Z-debug.log

Possible solution: Node's fs.mkdirSync() accepts a mode parameter - changing this to a higher than default value should allow for anyone's filesystem to create the directory without errors.

Refs: https://nodejs.org/dist/latest-v8.x/docs/api/fs.html#fs_fs_mkdirsync_path_mode