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

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

Open
NatoBoram opened this issue Apr 2, 2019 · 12 comments

Comments

@NatoBoram
Copy link

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
Copy link

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
Copy link

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

@dub71ca
Copy link

dub71ca commented Oct 1, 2020

The steps here fixed my permission issues

@gabriel-mars
Copy link

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

@fcole90
Copy link

fcole90 commented Mar 1, 2021

@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
Copy link

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

It solved my problem.

@fcole90
Copy link

fcole90 commented May 25, 2021

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

@Duduxs
Copy link

Duduxs commented Jul 19, 2021

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

Solved here, but idk exactly what this is 👀

@fcole90
Copy link

fcole90 commented Jul 20, 2021

--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
Copy link

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
Copy link

fcole90 commented Jul 24, 2021

@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
Copy link

--scripts-prepend-node-path

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

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

10 participants