Operating system and version:
ubuntu 16.04
nvm debug output:
root@ubuntu:~# nvm debug
nvm --version: v0.33.0
$SHELL: /bin/bash
$HOME: /root
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v6.10.0
which node: $NVM_DIR/versions/node/v6.10.0/bin/node
which iojs:
which npm: $NVM_DIR/versions/node/v6.10.0/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v6.10.0
npm root -g: $NVM_DIR/versions/node/v6.10.0/lib/node_modules
nvm ls output:root@ubuntu:~# nvm ls
v6.9.5
-> v6.10.0
default -> 6 (-> v6.10.0)
node -> stable (-> v6.10.0) (default)
stable -> 6.10 (-> v6.10.0) (default)
iojs -> N/A (default)
lts/* -> lts/boron (-> v6.10.0)
lts/argon -> v4.8.0 (-> N/A)
lts/boron -> v6.10.0
How did you install nvm? (e.g. install script in readme, homebrew):
curl script from readme
What steps did you perform?
npm i -g testcafe
What happened?
root@ubuntu:~# npm i -g testcafe
/root/.nvm/versions/node/v6.10.0/bin/testcafe -> /root/.nvm/versions/node/v6.10.0/lib/node_modules/testcafe/bin/testcafe.js
> [email protected] postinstall /root/.nvm/versions/node/v6.10.0/lib/node_modules/testcafe/node_modules/testcafe-browser-tools
> node ./bin/fix-permissions.js
sh: 1: node: Permission denied
/root/.nvm/versions/node/v6.10.0/lib
└── (empty)
npm ERR! Linux 4.9.7-x86_64-linode80
npm ERR! argv "/root/.nvm/versions/node/v6.10.0/bin/node" "/root/.nvm/versions/node/v6.10.0/bin/npm" "i" "-g" "testcafe"
npm ERR! node v6.10.0
npm ERR! npm v3.10.10
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] postinstall: `node ./bin/fix-permissions.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'node ./bin/fix-permissions.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the testcafe-browser-tools package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/fix-permissions.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs testcafe-browser-tools
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls testcafe-browser-tools
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /root/npm-debug.log
npm ERR! code 1
What did you expect to happen?
installation of testcafe globally
Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?
Not that I see.
curl -v nodejs.org/dist/ print out?
The error is coming from a postinstall script from testcafe-browser-tools (https://unpkg.com/[email protected]/bin/fix-permissions.js)
Looking at the script, it should be working fine - but the implication is that you used sudo at one time to nvm install node v6.10.0.
You'll either need to fix the permissions manually, or, nvm uninstall v6.10 && nvm install v6.10 (you will lose any installed global modules).
Thanks @ljharb. Any tips on how to resolve permissions manually? I gave chmod to /lib folder a shot, but admittedly I'm a bit of a linux n00b and it didn't work. Plus maybe it'd be a good look-up resource for others who have the same issue.
I'll also try your uninstall/install suggestion.
(BTW, I'm logged in as root in the machine.)
Some combination of chmod or chown should do it, but without having an open shell it's hard to tell you from here :-)
(separately, i'd encourage not using root for anything, including nvm; that shouldn't stop it from working, however)
FYI, nvm uninstall v6.10 && nvm install v6.10 didn't work for me, still couldn't install testcafe globally.
(Agreed about not using root, but just trying to get something working at the moment.)
root@ubuntu:~# ls -la /root/.nvm/versions/node/v6.10.0/
total 164
drwxr-xr-x 7 root root 4096 Mar 3 20:11 .
drwxr-xr-x 4 root root 4096 Mar 3 20:11 ..
drwxrwxr-x 2 500 500 4096 Mar 3 20:12 bin
-rw-rw-r-- 1 500 500 55606 Feb 22 00:27 CHANGELOG.md
drwxr-xr-x 2 root root 4096 Mar 3 20:11 etc
drwxrwxr-x 3 500 500 4096 Feb 22 00:27 include
drwxrwxr-x 3 500 500 4096 Feb 22 00:27 lib
-rw-rw-r-- 1 500 500 60255 Feb 22 00:27 LICENSE
-rw-rw-r-- 1 500 500 17535 Feb 22 00:27 README.md
drwxrwxr-x 5 500 500 4096 Feb 22 00:27 share
Also tried sudo chmod a+w /root/.nvm/versions/node/v6.10.0/lib
Which now shows:
root@ubuntu:~# ls -la /root/.nvm/versions/node/v6.10.0/
total 164
drwxrwxrwx 7 root root 4096 Mar 3 20:11 .
drwxr-xr-x 4 root root 4096 Mar 3 20:11 ..
drwxrwxr-x 2 500 500 4096 Mar 3 20:12 bin
-rw-rw-r-- 1 500 500 55606 Feb 22 00:27 CHANGELOG.md
drwxr-xr-x 2 root root 4096 Mar 3 20:11 etc
drwxrwxr-x 3 500 500 4096 Feb 22 00:27 include
drwxrwxrwx 3 500 500 4096 Feb 22 00:27 lib
-rw-rw-r-- 1 500 500 60255 Feb 22 00:27 LICENSE
-rw-rw-r-- 1 500 500 17535 Feb 22 00:27 README.md
drwxrwxr-x 5 500 500 4096 Feb 22 00:27 share
Still no luck with npm i -g testcafe
Just to confirm, is this just a problem with testcafe?
Some things work fine, like http-server and pm2.
But vorlon does not either, though it installs fine on my Windows machine.
root@ubuntu:~# npm i -g vorlon
npm WARN deprecated [email protected]: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated [email protected]: Deprecated, use jstransformer
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: use uuid module instead
/root/.nvm/versions/node/v6.10.0/bin/vorlon -> /root/.nvm/versions/node/v6.10.0/lib/node_modules/vorlon/bin/vorlon
> [email protected] install /root/.nvm/versions/node/v6.10.0/lib/node_modules/vorlon/node_modules/phantomjs-preb uilt
> node install.js
sh: 1: node: Permission denied
/root/.nvm/versions/node/v6.10.0/lib
└── (empty)
npm ERR! Linux 4.9.7-x86_64-linode80
npm ERR! argv "/root/.nvm/versions/node/v6.10.0/bin/node" "/root/.nvm/versions/node/v6.10.0/bin/npm" "i" "-g" "vorlon"
npm ERR! node v6.10.0
npm ERR! npm v3.10.10
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] install: `node install.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] install script 'node install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the phantomjs-prebuilt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs phantomjs-prebuilt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls phantomjs-prebuilt
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /root/npm-debug.log
npm ERR! code 1
The common thread seems to be global packages that have postinstall scripts that check/fix permissions. I would still suspect that it's because you're root - npm runs postinstall scripts as nobody for safety.
Let's call this one fixed! :)
I followed the instructions here to create a sudo user (called it worker1): https://www.digitalocean.com/community/tutorials/how-to-create-a-sudo-user-on-ubuntu-quickstart
Then reinstalled nvm in that account. Then:
worker1@ubuntu:~$ npm install testcafe
> [email protected] postinstall /home/worker1/node_modules/testcafe-browser-tools
> node ./bin/fix-permissions.js
File permissions fixed
/home/worker1
└─┬ [email protected]
. . .
I don't fully understand the ramifications of using a non-root user, but it's enough to nod my head, cheer, and move along :) Thanks for your help working through this; muchly appreciated kind sir! :+1: May others find this useful as well.
Glad you got something working!
You can run this as root
npm config set user 0
npm config set unsafe-perm true
npm install -g package
unsafe-perm is unsafe tho; you shouldn't need sudo or unsafe perms to do anything with node/npm.
@ljharb right, if for some reason someone want to use it with root that should work.
Had this issue when trying to set up a Dockerfile to handle my dependencies.
https://github.com/creationix/nvm/issues/1407#issuecomment-316858947 fixed it for me as well. I ended up creating my Dockerfile like this:
Dockerfile:
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
ADD setup_nvm.sh setup_nvm.sh
RUN sh ./setup_nvm.sh
setup_nvm.sh
#!/usr/bin/env sh
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
nvm install node
npm config set user 0
npm config set unsafe-perm true
npm install -g npm
npm install package
npm config set user 0
npm config set unsafe-perm true
Woks.
Im trying to install Tronbox and Im egtting this error can someone please chat with me to help? https://www.facebook.com/camjacko
Last login: Wed Jun 26 13:04:01 on ttys002
Camerons-iMac:~ Jacko$ git clone https://github.com/ThisIsCodeXpert/CodeXpert-Tron-DApp-Template.git
fatal: destination path 'CodeXpert-Tron-DApp-Template' already exists and is not an empty directory.
Camerons-iMac:~ Jacko$ npm install -g tronbox
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! stack:
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! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Jacko/.npm/_logs/2019-06-26T09_12_04_096Z-debug.log
Camerons-iMac:~ Jacko$ root/Administrator npm install -g tronbox
-bash: root/Administrator: No such file or directory
Camerons-iMac:~ Jacko$ /Users/Jacko/.npm/_logs/2019-06-26T09_12_04_096Z-debug.log
-bash: /Users/Jacko/.npm/_logs/2019-06-26T09_12_04_096Z-debug.log: Permission denied
Camerons-iMac:~ Jacko$
@horseracetron you need to use sudo with npm install -g when you’re not using nvm (note that because you’re not using nvm, this repo doesn’t apply to your issue)
TLDR; don't run npm commands as root.
I just wanted to note here in line with @ljharb that it is highly discouraged to run npm commands as root. Essentially this installs global JS modules (that are often updated) across the whole filesystem and can be used by any process, within or out of your control.
EDIT:
@britho fwiw the install scripts run as nobody, so the security risk is actually minimal.
@britho fwiw the install scripts run as nobody, so the security risk is actually minimal.
sudo find ~/.nvm/ -type d -user root -exec sudo chown -R $USER: {} +
Works here
Most helpful comment
You can run this as root
npm config set user 0
npm config set unsafe-perm true
npm install -g package
source