Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postinstall script fails on Linux when installing globally using sudo #19

Open
RaederDev opened this issue Nov 10, 2016 · 6 comments
Open

Comments

@RaederDev
Copy link

When installing the package on Linux using sudo:
"sudo npm install -g nwjs"

The postinstall script fails because the process loses elevated privileges most likely due to invoking the "node" command.

/usr/bin/nw -> /usr/lib/node_modules/nwjs/nw

> [email protected] postinstall /usr/lib/node_modules/nwjs
> node postinstall.js

shell.js: internal error
Error: EACCES: permission denied, mkdir '/root/.nwjs'
    at Object.fs.mkdirSync (fs.js:846:18)
    at mkdirSyncRecursive (/usr/lib/node_modules/nwjs/node_modules/shelljs/src/mkdir.js:11:8)
    at /usr/lib/node_modules/nwjs/node_modules/shelljs/src/mkdir.js:63:7
    at Array.forEach (native)
    at _mkdir (/usr/lib/node_modules/nwjs/node_modules/shelljs/src/mkdir.js:48:8)
    at /usr/lib/node_modules/nwjs/node_modules/shelljs/src/common.js:240:23
    at Object.<anonymous> (/usr/lib/node_modules/nwjs/postinstall.js:6:1)
    at Module._compile (module.js:573:32)
    at Object.Module._extensions..js (module.js:582:10)
    at Module.load (module.js:490:32)
npm ERR! Linux 4.8.6-1-ARCH

The workaround I found was elevating to root before invoking npm and then manually creating the cache directory for the correct user "mkdir ~/.nwjs". However since this is the first time I've encountered an issue like that with a global npm package this can probably be considered a bug.

Another issue with creating the directory at install time is: Should the directory ever be removed or the command be invoked by another user the nw command will fail:

> nw ls
Error: ENOENT: no such file or directory, scandir '/home/benni/.nwjs'

This could be fixed if the command would create the directory at runtime and not during installation.

@mythril
Copy link

mythril commented Dec 3, 2016

I think I ran into the same problem: https://gitter.im/nwjs/nw.js?at=5842fc4290f847041bf2fb7e

@mythril
Copy link

mythril commented Dec 3, 2016

@alejandro11k
Copy link

my solution:
first make directory manually
mkdir /home/user/.nwjs
and then
sudo npm i -g nwjs
xubuntu 16.04

@dotbloup
Copy link

dotbloup commented Jan 7, 2019

I had a similar issue
during install of npm i nwjs -g
it stated mkdir: cannote create direct /user/MYNAME/.nwjs

Ubuntu 18.10

I manually created /user/myname/.nwjs before doing nw install 0.35.4-sdk

@fritx
Copy link
Collaborator

fritx commented Jan 10, 2019

You guys might have permission problems with node.js (needs sudo).

It is recommended to use nvm to manage (multiple) node.js versions painlessly, with no more permission issues :)

nvm installs node.js in user directory not root.

https://github.com/creationix/nvm

@dotbloup
Copy link

dotbloup commented Jan 10, 2019

this may work using on linux

sudo npm i -g nwjs --unsafe-perm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants