admc / wd

A node.js client for webdriver/selenium 2.
Other
1.53k stars 402 forks source link

Cannot create user data directory: /nonexistent/snap/node/1889: Permission denied #586

Open NatoBoram opened 5 years ago

NatoBoram commented 5 years ago

I was trying to sudo npm install -g polymer-cli, when suddenly, wd tried to create /nonexistent/snap/node/1889. I don't really know what's happening, so I'm reporting it here.

> wd@1.11.1 install /usr/local/lib/node_modules/polymer-cli/node_modules/wd
> node scripts/build-browser-scripts

2019/04/02 12:25:27.948178 cmd_run.go:876: WARNING: cannot create user data directory: cannot create "/nonexistent/snap/node/1889": mkdir /nonexistent: permission denied
cannot create user data directory: /nonexistent/snap/node/1889: Permission denied

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wd@1.11.1 install: `node scripts/build-browser-scripts`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the wd@1.11.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
node --version
v12.0.0-nightly2019040166b95362df

npm -version
6.9.0

neofetch --off
nato@nato-heos 
-------------- 
OS: elementary OS 5.0 Juno x86_64 
Kernel: 4.15.0-47-generic 
Uptime: 21 hours, 26 mins 
Packages: 2329 
Shell: bash 4.4.19 
Resolution: 1920x1080 
DE: Pantheon 
WM: Mutter(Gala) 
Theme: Elementary [GTK3] 
Icons: Elementary [GTK3] 
Terminal: io.elementary.t 
CPU: Intel i5-3570K (4) @ 4.100GHz 
GPU: NVIDIA GeForce GTX 660 Ti 
Memory: 6261MiB / 7920MiB 
HafizKurniaAji commented 5 years ago

That's happened because you install NodeJs using Snap package from Snap Store, which is had different permission with packages are installed from APT https://snapcraft.io/docs/permission-requests

You can uninstall/remove currently installation, after that you should re-install using APT, follow instruction from https://github.com/nodesource/distributions#debinstall

brunohonda commented 4 years ago

Try use option --scripts-prepend-node-path to run npm command

dub71ca commented 4 years ago

The steps here fixed my permission issues

gabriel-mars commented 3 years ago

@brunohonda thank you! That's worked for me.

fcole90 commented 3 years ago

@hafizkurniaaji Node is installed with --classic confinement, so it has access to the whole system. The only part it cannot edit is what is under /snap. So normally an npm package will be installed under /usr and will need administrator privileges, or the packages location should be changed using https://docs.npmjs.com/getting-started/fixing-npm-permissions (which had already been linked).

Still, this doesn't make clear why the original error appear. Does wd attempts to make any filesystem operation in the same folder where node lies?

harsh863 commented 3 years ago

Try use option --scripts-prepend-node-path to run npm command

It solved my problem.

fcole90 commented 3 years ago

If using the snap, it could also be related to https://github.com/nodejs/node/issues/37982 and https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1849753

Duduxs commented 3 years ago

Try use option --scripts-prepend-node-path to run npm command

Solved here, but idk exactly what this is 👀

fcole90 commented 3 years ago

--scripts-prepend-node-path

npm run sets the NODE environment variable to the node executable with which npm is executed. Also, if the --scripts-prepend-node-path is passed, the directory within which node resides is added to the PATH. If --scripts-prepend-node-path=auto is passed (which has been the default in npm v3), this is only performed when that node executable is not found in the PATH.

From https://docs.npmjs.com/cli/v6/commands/npm-run-script

Yog4Prog commented 3 years ago

Run following commands.. It worked for me 1) sudo apt-get update 2) sudo apt-get install nodejs ( #### Reinstall nodejs ) 3) sudo npm install -g @angular/cli ( I was facing issue with angular installation.. but your case might be with different installation )

fcole90 commented 3 years ago

@Yog4Prog yes, that's node package from the archives. The issue is likely because of the node snap, see my previous comment:

If using the snap, it could also be related to nodejs/node#37982 and https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1849753

Many people solved similar issues also by following Option 2 described here: https://npm.github.io/installation-setup-docs/installing/a-note-on-permissions.html

Jemeni11 commented 3 years ago

--scripts-prepend-node-path

This worked perfectly thanks I ended up using: sudo npm install -g @vue/cli --scripts-prepend-node-path