Global install of phantomjs-prebuilt in Debian stretch - phantomjs

I'm trying to do a global install of phantomjs-prebuilt in a Debian Stretch VM. I realise there is a prebuilt Debian package, but...
Here's the result:
root#debian:~# npm install phantomjs-prebuilt -g
/usr/bin/phantomjs -> /usr/lib/node_modules/phantomjs-prebuilt/bin/phantomjs
> phantomjs-prebuilt#2.1.14 install /usr/lib/node_modules/phantomjs-prebuilt
> node install.js
Considering PhantomJS found at /usr/bin/phantomjs
Looks like an `npm install -g`
Could not link global install, skipping...
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2
Saving to /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
Receiving...
[========================================] 100%
Received 22866K total.
Extracting tar contents (via spawned process)
Removing /usr/lib/node_modules/phantomjs-prebuilt/lib/phantom
Copying extracted folder /tmp/phantomjs/phantomjs-2.1.1-linux-
x86_64.tar.bz2-extract-1498865633866/phantomjs-2.1.1-linux-x86_64 -> /usr/lib/node_modules/phantomjs-prebuilt/lib/phantom
Phantom installation failed { Error: EACCES: permission denied, link '/tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1498865633866/phantomjs-2.1.1-linux-x86_64' -> '/usr/lib/node_modules/phantomjs-prebuilt/lib/phantom'
errno: -13,
code: 'EACCES',
syscall: 'link',
path: '/tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1498865633866/phantomjs-2.1.1-linux-x86_64',
dest: '/usr/lib/node_modules/phantomjs-prebuilt/lib/phantom' } Error: EACCES: permission denied, link '/tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1498865633866/phantomjs-2.1.1-linux-x86_64' -> '/usr/lib/node_modules/phantomjs-prebuilt/lib/phantom'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! phantomjs-prebuilt#2.1.14 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the phantomjs-prebuilt#2.1.14 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-06-30T23_33_57_117Z-debug.log
If I'm reading it right, it seems odd that it would download the tarball to /tmp, extract the tarball and then create a symlink to the /tmp file(s) in /usr/lib/node_modules.
Am I just doing it wrong? Other npm packages seem ok:
root#debian:~# npm install -g grunt-cli
/usr/bin/grunt -> /usr/lib/node_modules/grunt-cli/bin/grunt
+ grunt-cli#1.2.0
added 16 packages in 1.511s
In case it matters:
root#debian:~# node -v
v8.1.2
root#debian:~# npm -v
5.0.3

Related

How do you install Firebase tools in a Gitlab CI Runner?

I'm having some trouble configuring Gitlab CI to run firebase emulators. In particular, it's failing to install firebase-tools. This is the relevant part of my config
unit-test-job: # This job runs in the test stage.
image: node:14.14.0
artifacts:
paths:
- "test-results.xml"
reports:
junit: "test-results.xml"
stage: test
script:
- apt-get update && apt-get install -y openjdk-8-jdk
- npm i
- npm i -g firebase-tools
- firebase use $MY_PROJECT
- echo "Running unit tests..."
- npm run test:ci
When trying to install firebase-tools I get this error from the CI
$ npm i -g firebase-tools
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated uuid#3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated har-validator#5.1.5: this library is no longer supported
/usr/local/bin/firebase -> /usr/local/lib/node_modules/firebase-tools/lib/bin/firebase.js
> re2#1.16.0 install /usr/local/lib/node_modules/firebase-tools/node_modules/re2
> install-from-cache --artifact build/Release/re2.node --host-var RE2_DOWNLOAD_MIRROR || npm run rebuild
Trying https://github.com/uhop/node-re2/releases/download/1.16.0/linux-x64-83.br ...
Writing to build/Release/re2.node ...
Trying https://github.com/uhop/node-re2/releases/download/1.16.0/linux-x64-83.gz ...
Writing to build/Release/re2.node ...
Building locally ...
npm ERR! code EACCES
npm ERR! syscall scandir
npm ERR! path /root/.npm/_logs
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 65534:0 "/root/.npm"
glob error [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] {
errno: -13,
code: 'EACCES',
syscall: 'scandir',
path: '/root/.npm/_logs'
}
> re2#1.16.0 rebuild /usr/local/lib/node_modules/firebase-tools/node_modules/re2
> node-gyp rebuild
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/root/.cache/node-gyp/14.14.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/firebase-tools/node_modules/re2/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/firebase-tools/node_modules/re2/.node-gyp'
gyp ERR! System Linux 5.4.109+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/firebase-tools/node_modules/re2
gyp ERR! node -v v14.14.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! re2#1.16.0 rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the re2#1.16.0 rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Any suggestions on how to fix this?
You're actually encountering an issue that isn't necessarily related to gitlab-ci, but it actually related to node 14. Essentially that /root/.npm folder has bad permissions in node 14. You have three ways you can fix this:
Update to Node 15 (just change your image to node:15) which fixes the permission issue
Allow node permissions to scan the folder. This is insinuated by the error message you have in the above error where it tells you the directory can't be scanned. The easiest way to resolve this issue is to remove the -g off the second node install, which will make it deploy to the user folder instead of global. Since you're rebuilding the container every time and using the same user each time, the -g to install globally is redundant in this case.
Install Firebase using the standalone method to get the CLI instead of using NPM to install it. You can do this in a docker container using curl -sL firebase.tools | sed 's/sudo //g' | bash
Hopefully this helps!

How to update npm in Laravel Sail

I am currently using Laravel 8.48.2 with the Sail package. I set Sail up and running its image through Docker Desktop while using WSL 2 with a Ubuntu distro on Windows. All seems to be working fine.
After I ran sail npm install, the packages were installed successfully, but I received the following message:
npm notice New minor version of npm available! 7.18.1 -> 7.19.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.19.0
npm notice Run npm install -g npm#7.19.0 to update!
Therefore, I tried running sail npm install -g npm#7.19.0 which gave me the following message:
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/lib/node_modules/npm
npm ERR! dest /usr/lib/node_modules/.npm-qUIFSsiV
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm-qUIFSsiV'
npm ERR! [Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm-qUIFSsiV'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/lib/node_modules/npm',
npm ERR! dest: '/usr/lib/node_modules/.npm-qUIFSsiV'
npm ERR! }
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.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/sail/.npm/_logs/2021-06-26T15_27_02_291Z-debug.log
How can I update the NPM version on Sail?
Thank you in advance.
Current working method:
sail root-shell
npm install -g npm#latest
Looking at your log it seems the user you run as has insufficient permission on the folder /usr/lib/node_modules/. So what you might try is to log in to the container with docker-compose exec laravel.test bash and use chown -R user:group /usr/lib/node_modules/ with the current user and group (found by whoami). Or chmod the folder to have more looser permission overall on this folder.
Thanks to #online Thomas (https://stackoverflow.com/a/68173952/14508436), in order to resolve my issue, I followed these steps:
Within my Laravel project's directory, I ran this command... docker-compose exec laravel.test bash, which points you to the docker's server (or something like that), directly on your project's directory.
I ran this command... npm install -g npm#7.19.0 which updated npm to a newer version without any issues.
I tried the chown and chmod commands as suggested by #online Thomas, but in vain. I still couldn't use the sail npm install -g npm#7.19.0 command outside of the docker's server.

Angular CLI on HTTPS - can't install CI as root

I need to have my angular app over https port 443. To do that, I need to run ng as root. However, I can not get Angular CLI to install as root. Any suggestions?
root#develop:~# n v9.4.0
install : node-v9.4.0
mkdir : /root/n/n/versions/node/9.4.0
fetch : https://nodejs.org/dist/v9.4.0/node-v9.4.0-linux-x64.tar.gz
######################################################################### 100.0%
installed : v9.4.0
root#develop:~# npm install -g #angular/cli
/root/n/bin/ng -> /root/n/lib/node_modules/#angular/cli/bin/ng
> #angular/cli#8.2.0 postinstall /root/n/lib/node_modules/#angular/cli
> node ./bin/postinstall/script.js
sh: 1: node: Permission denied
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! #angular/cli#8.2.0 postinstall: `node ./bin/postinstall/script.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the #angular/cli#8.2.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-08-07T14_07_14_142Z-debug.log
By default npm takes some steps to avoid running scripts as root. You can override this with --unsafe-perm:
# npm install -g --unsafe-perm #angular/cli
(As an aside: you do not need to install angular as root to run your eventual service as root, but that is a longer answer with more context needed.)

Issues installing fabric-sdk-rest

I am trying to install hyperledger fabric sdk rest server. I have cloned fabric-sdk-rest repo and installed the prerequisites but when trying to run "npm link" in packages/loopback-connector-fabric I get the following error:
npm ERR! path /usr/lib/node_modules/loopback-connector-fabric
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall unlink
npm ERR! Error: EACCES: permission denied, unlink '/usr/lib/node_modules/loopback-connector-fabric'
npm ERR! { Error: EACCES: permission denied, unlink '/usr/lib/node_modules/loopback-connector-fabric'
npm ERR! stack: 'Error: EACCES: permission denied, unlink \'/usr/lib/node_modules/loopback-connector-fabric\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'unlink',
npm ERR! path: '/usr/lib/node_modules/loopback-connector-fabric' }
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! /home/user/.npm/_logs/2018-02-12T22_24_45_379Z-debug.log
This is what happens if I run it with sudo:
> pkcs11js#1.0.13 install /home/user/Documents/fabric-sdk-rest/packages/loopback-connector-fabric/node_modules/pkcs11js
> node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/user/Documents/fabric-sdk-rest/packages/loopback-connector-fabric/node_modules/pkcs11js/build'
gyp ERR! System Linux 4.8.0-36-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/user/Documents/fabric-sdk-rest/packages/loopback-connector-fabric/node_modules/pkcs11js
gyp ERR! node -v v9.5.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pkcs11js#1.0.13 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pkcs11js#1.0.13 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2018-02-12T22_26_40_864Z-debug.log
This is done in Ubuntu 16.04. What am I doing wrong?
I was facing this errors too. After a while trying all kind of insane things to get it running I came into account that the problem was I was installing npm modules as superuser globally. This conflicts with hyperledger*.
Solutions is $: sudo npm uninstall -g *** for every module you just installed as superuser.
Then you need to install the modules not as superuser. This are some advices.
If installing Hyperledger Composer using Linux, be aware of the following advice:
Login as a normal user, rather than root.
Do not su to root.
When installing prerequisites, use curl, then unzip using sudo.
Run prereqs-ubuntu.sh as a normal user. It may prompt for root password as some of it's actions are required to be run as
Do not use npm with sudo or su to root to use it.
Avoid by all means installing node modules globally as root.
If you're running on Ubuntu, you can download the prerequisites using the following commands:
curl -O https://hyperledger.github.io/composer/prereqs-ubuntu.sh
chmod u+x prereqs-ubuntu.sh
Next run the script - as this briefly uses sudo during its execution, you will be prompted for your password.
$: ./prereqs-ubuntu.sh
This is the best way
Or you can visit this page and follow the prereqs installation guide.
Prerequisites for Ubuntu
and finally follow this link to continue the installation it works just fine.
Install development tools
This is the latest update
Hope this helps

Error installing Dalek JS Module - Chrome Browser

I'm having trouble installing the Chrome Browser Dalek JS Module.
Here's an extract from the console output:
npm http 304 https://registry.npmjs.org/abbrev
> dalek-browser-chrome#0.0.2 install /Users/xxx/Sites/tests/node_modules/dalek-browser-chrome
> node install.js
Chromedriver installation failed Error: EACCES, permission denied '/Users/xxx/tmp/chromedriver'
at Object.fs.unlinkSync (fs.js:582:18)
at rimrafSync (/Users/xxx/Sites/tests/node_modules/dalek-browser-chrome/node_modules/rimraf/rimraf.js:154:8)
at Promise._successFn (/Users/xxx/Sites/tests/node_modules/dalek-browser-chrome/install.js:176:7)
at Promise._withInput (/Users/xxx/Sites/tests/node_modules/dalek-browser-chrome/node_modules/kew/kew.js:204:25)
at Promise._chainPromise (/Users/xxx/Sites/tests/node_modules/dalek-browser-chrome/node_modules/kew/kew.js:244:13)
at Promise.then (/Users/xxx/Sites/tests/node_modules/dalek-browser-chrome/node_modules/kew/kew.js:144:13)
at /Users/xxx/Sites/tests/node_modules/dalek-browser-chrome/install.js:175:23
at loadCbs.length (/Users/xxx/Sites/tests/node_modules/dalek-browser-chrome/node_modules/npmconf/npmconf.js:76:7)
at Array.forEach (native)
at /Users/xxx/Sites/tests/node_modules/dalek-browser-chrome/node_modules/npmconf/npmconf.js:75:13
npm ERR! dalek-browser-chrome#0.0.2 install: `node install.js`
npm ERR! `sh "-c" "node install.js"` failed with 1
npm ERR!
npm ERR! Failed at the dalek-browser-chrome#0.0.2 install script.
npm ERR! This is most likely a problem with the dalek-browser-chrome 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 their info via:
npm ERR! npm owner ls dalek-browser-chrome
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 12.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "dalek-browser-chrome" "--save-dev"
npm ERR! cwd /Users/xxx/Sites/tests
npm ERR! node -v v0.8.15
npm ERR! npm -v 1.1.66
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/xxx/Sites/tests/npm-debug.log
npm ERR! not ok code 0
i'm running Mac OS X 10.8.4. it looks like a permissions issue, but i'm running the install as follows:
sudo npm install dalek-browser-chrome --save-dev
UPDATE
I did try running this without sudo first - but got the following:
── ncp#0.4.2
├── kew#0.1.7
├── q#0.9.6
├── adm-zip#0.4.3
├── rimraf#2.2.2 (graceful-fs#2.0.0)
└── npmconf#0.1.2 (once#1.1.1, inherits#2.0.1, osenv#0.0.3, ini#1.1.0, mkdirp#0.3.5, semver#2.1.0, nopt#2.1.2, config-chain#1.1.7)
npm ERR! Error: EACCES, open '/Users/xxx/Sites/tests/package.json'
npm ERR! { [Error: EACCES, open '/Users/xxx/Sites/tests/package.json']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/Users/xxx/Sites/tests/package.json' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 12.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "dalek-browser-chrome" "--save-dev"
npm ERR! cwd /Users/xxx/Sites/tests
npm ERR! node -v v0.8.15
npm ERR! npm -v 1.1.66
npm ERR! path /Users/xxx/Sites/tests/package.json
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, open '/Users/xxx/Sites/tests/package.json'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/xxx/Sites/tests/npm-debug.log
npm ERR! not ok code 0
Based on this I tried it with Sudo.
Any idea what else it might be?
The chromedriver module is attempting to run an install script that touches files outside of the module's directory.
This is a bug with the chromedriver module. It should not be trying to touch any files outside of its module folder at install time. If this is absolutely necessary, it can ask for permission from you at run time and do what it needs to do.
In order to prevent surprising exploits, npm runs package lifecycle scripts as nobody when you are running npm as root. The nobody user doesn't have permission to write to /Users/xxx/tmp (weird username you've chosen, btw), so the install script fails.
What if a package were to write to /etc/hosts or something, and add a bunch of phishing site IP addresses as the location for various bank websites? If you download a command, and then run it, and it does some bad stuff, ok, you screwed up and trusted the wrong program. But if simply installing the program does some bad stuff like this, then npm has violated your trust, and I try not to let that happen.
You could argue that you've explicitly asked to download the program, but since the web of trust with small dependencies can get very wide, it's just a bit too dangerous for me to sleep well at night, so that's why npm has this rule.
The problem could be related with the use of sudo,
the module is a local one, so you should be able to install it without the use of sudo.
After the chromedriver executable is downloaded, the installer tries to fix the permissions of the downloaded file, which might result in this problem.
Further read on to sudo or not: http://howtonode.org/introduction-to-npm