How to install node-red-admin in docker image

Hello,
I would like to secure my node-red installation using user/password.
So I would need to use node-red-admin tool to generate the password hash.
I am using the nodered/node-red-docker docker image.
I tried to login into container and then to install node-red-admin via npm but I got a permission error

node-red@europa:/data$ npm install -g node-red-admin
npm info it worked if it ends with ok
npm info using npm@5.0.3
npm info using node@v8.1.3
npm http fetch GET 200 https://registry.npmjs.org/node-red-admin 128ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/bcryptjs 167ms (from cache)
[snip]
npm http fetch GET 200 https://registry.npmjs.org/psl 22ms (from cache)
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /usr/src/node-red/.npm/_logs/2019-05-07T08_15_26_430Z-debug.log

How can I fix it?
Is the tool already installed? In this case what is the path?
Is there any other way o generate password hashes?

Thank You

Regards

See the alternative command in the docs
https://nodered.org/docs/security

1 Like