npm install failes with ERR! tar.unpack (raspi) - node.js

I try to install Selenium Code Line Runner following this tutorial
https://www.seleniumhq.org/selenium-ide/docs/en/introduction/command-line-runner/
I managed to sudo apt-get install nodejs and sudo apt-get install npm
but I failed with installing selenium-side-runner via sudo npm install -g selenium-side-runner
I get the following error:
npm ERR! tar.unpack ...
See also: error messages
I stumbled upon some tricks as follows:
Installation to SD Card (Raspi)
Card is not full
sudo npm cache clean and retry didn't work
sudo rm -r /usr/local/lib/node_modules/selenium-side-runner and retry didn't work
Any other ideas?

An update of NPM did it!
sudo npm install -g npm#latest

Related

npm install global in Dockerfile

Trying to install resume-cli through docker but getting some permission errors on installing resume-cli.
Dockerfile:
FROM python:3.7-slim-buster
RUN apt-get update
RUN apt-get install -y curl
SHELL ["/bin/bash", "--login", "-c"]
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
RUN nvm install 15.13.0
RUN npm install -g resume-cli --unsafe-perm=true --allow-root
RUN npm install -g jsonresume-theme-paper
and i run: docker build -t containernpm .
where I get Error on RUN npm install -g resume-cli --unsafe-perm=true --allow-root:
npm ERR! code 127
npm ERR! path /root/.nvm/versions/node/v15.13.0/lib/node_modules/resume-cli/node_modules/puppeteer
npm ERR! command failed
npm ERR! command sh -c node install.js
npm ERR! sh: 1: node: Permission denied
btw next line RUN npm install -g jsonresume-theme-paper (with -g) runs normally without permission error.
Any idea how to overpass that without removing -g on RUN npm install -g resume-cli --unsafe-perm=true --allow-root
? (by removing -g runs without error)
I can't say I know why the permissions errors are happening, but here is a Dockerfile that works.
FROM node:15.13.0-buster-slim
RUN npm install -g resume-cli
ENTRYPOINT ["resume"]
There is a related question (sh: 1: node: Permission denied) but the top-voted answer there does not work for me.

Permission denied while trying to install opencv4nodejs in Ubuntu

I was trying to install opencv4nodejs in Ubuntu-20.04 using the following command and my node version is v12.19.0
sudo npm i -g opencv4nodejs
But getting those errors
info install installing opencv version 3.4.6 into directory: /usr/lib/node_modules/opencv4nodejs/node_modules/opencv-build/opencv
ERR! Error: Command failed: mkdir -p opencv
mkdir: cannot create directory ‘opencv’: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! opencv-build#0.1.9 install: `node ./install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the opencv-build#0.1.9 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/2020-10-28T06_33_21_090Z-debug.log
Running NPM install with sudo might be causing a permissions problem. You could try completely removing the node_modules directory and re-running NPM install it without sudo.
Also make sure you have permission to write to the directory you're installing in?
If it still doesn't work please follow this:
sudo npm install -g opencv4nodejs --unsafe-perm=true --allow-root
This is complete guide to install opencv4nodejs to Linux OS or Raspberry pi (Raspberry Pi OS )
configuration
01- sudo raspi-config expand file system // this is for raspberry pi
After Reboot (sudo reboot now)
02- df -h (To check expand file system)
03- sudo apt-get update && sudo apt-get upgrade -y
04- sudo passwd root // set up your root password
Reboot
To Install NodeJS
01- sudo apt-get install git -y
02- curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - // replase 12 with latest nodejs (LTS) version
03- sudo apt-get install nodejs -y
04- sudo apt-get install gcc g++ make
To Install opencv4nodejs
01. sudo apt-get install cmake -y
02. sudo npm install -g node-gyp
I am using this steps for raspberry pi os
03. sudo nano /etc/dphys-swapfile
(Increase the CONF_SWAPSIZE from 100 to 1024)
sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start
cd to home dir..
04. mkdir opencv
05. cd opencv
06. sudo npm init -y
07. su
// Enter your setup root password
08. sudo npm install --save opencv4nodejs
09. sudo nano /etc/dphys-swapfile
(Set the CONF_SWAPSIZE back to 100)
In index.js and node_modules in same folder
const cv = require("opencv4nodejs");
In index.js and node_modules in not in same folder
const cv = require("path/opencv/node_modules/opencv4nodejs");
! you don't need to install opencv4nodejs for each folders
You can simply call that above way
Hope guys you can understand it...
Any questions feel free to ask...
Thank you

npm install puppeteer showing permission denied errors

I'm unable to install puppeteer as a project dependency, and I've tried re-installing node. Anyone have an idea on how to fix this? Running Ubuntu 17.10 x64
sudo apt-get purge nodejs;
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -;
apt-get install -y nodejs;
sudo npm install -g n;
sudo n stable;
Node versions:
$ node -v
v9.4.0
$ npm -v
5.6.0
I try to install:
root#server:/var/www/html# npm install --save puppeteer
Error message:
> puppeteer#1.1.0 install /var/www/html/node_modules/puppeteer
> node install.js
ERROR: Failed to download Chromium r536395! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download.
{ Error: EACCES: permission denied, mkdir '/var/www/html/node_modules/puppeteer/.local-chromium'
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path: '/var/www/html/node_modules/puppeteer/.local-chromium' }
npm WARN project#1.0.0 No description
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! puppeteer#1.1.0 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the puppeteer#1.1.0 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/2018-02-19T15_55_52_669Z-debug.log
I don't see any ways to fix this in the referenced issue: https://github.com/GoogleChrome/puppeteer/issues/375
EDIT 20th April 2019:
The easy solution suggested by lauraalvarezz1 is,
sudo npm install -g puppeteer --unsafe-perm=true
This is okay as long as you trust puppeteer and want it to install puppeteer globally.
However beware of using --unsafe-perm=true for permission related problems. Reasons are:
Running unsafe-perm=true with sudo, as a non-root user, will give the script root access. This might be okay only if you trust the script and do not concern about security that much.
You might need to use --no-sandbox in every script you run, because the chrome installed with this command might not run without this parameter. See this github issue.
You have installed npm with sudo. Thus anything you install globally will require sudo.
To install anything on var/www/html folder, either you have to own that folder,
sudo chown -R $USER /var/www/html
Or you can use nvm to manage npm. Technically it will use your home directory and your current user.
After installing nvm, you can install puppeteer globally with it,
npm i -g puppeteer
or you have to use sudo
sudo npm install --save puppeteer
However chromium will not be downloaded due to permission error, that's why you have to use ---unsafe-perm=true as stated before.
Security Related Resources:
Resolve this without sudo, you can use this answer.
Learn more about best practices dealing with /var/www folder, refer to this answer.
Best of luck!
Run this on your terminal:
sudo npm install -g puppeteer --unsafe-perm=true
Before you begin, make sure you have the most recent version of Node.js.
The Puppeteer Documentation states:
Note: Puppeteer requires at least Node v6.4.0, but the examples below use async/await which is only supported in Node v7.6.0 or greater.
You can check which version of Node.js you have using the following command:
node -v
# OR nodejs -v
If your version of Node.js is less then v7.6.0, you can completely uninstall your current version of Node.js.
Then, you can use complete the reinstallation using a PPA:
sudo apt update
curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt install nodejs
sudo apt install build-essential
You can check the new versions of Node.js and NPM installed on your system:
node -v
npm -v
Finally, you can install Puppeteer:
sudo npm install puppeteer --unsafe-perm=true --allow-root
Now you can run Puppeteer scripts using the node command:
node puppeteer-script.js
I did:
yarn install --ignore-scripts
yarn install.
And it worked without sudo or global package installation.
It should work with npm too.
I have Ubuntu 20.04.

Installing Phonegap on Ubuntu 13.10

I am completely stuck.
I have tried using the guide on http://www.jakenovak.com/installing-phonegap-on-ubuntu-13-10-with-local-android-package-building/
Then I tried using the latest ppa via:
sudo apt-get update
sudo apt-get install -y python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
but whatever I attempt to install phone gap via
sudo npm install -g phonegap
or
sudo npm install -gf phonegap
I get the error:
npm http GET http://registry.npmjs.org/phonegap
npm http 304 http://registry.npmjs.org/phonegap
npm http GET http://registry.npmjs.org/phonegap/-/phonegap-3.3.0-0.19.5.tgz
npm http 200 http://registry.npmjs.org/phonegap/-/phonegap-3.3.0-0.19.5.tgz
npm ERR! TypeError: Arguments to path.resolve must be strings
npm ERR! at Object.exports.resolve (path.js:313:15)
npm ERR! at Object.exports.relative (path.js:370:20)
This seems like an npm error but I am not sure how to resolve it.
Any help would be very welcome.
Thanks,
Fido
Okay I managed to figure this out. It was a duplication error on my part. I had two versions of npm installed. Version 1.1 etc which kept producing the error, when I switched to the correct version 1.3.24 this error resolved itself. I am guessing that simply upgrading npm resolves this issue.

"message failed to fetch from registry" while trying to install any module

I can't install any node module from the npm.
npm install socket.io
The above command resulted to below output, it is not able to install socket.io
npm http GET https://registry.npmjs.org/socket.io
npm ERR! Error: failed to fetch from registry: socket.io
npm ERR! at /opt/node0610/lib/node_modules/npm/lib/utils/npm-registry-client/get.js:139:12
npm ERR! at cb (/opt/node0610/lib/node_modules/npm/lib/utils/npm-registry-client/request.js:32:9)
npm ERR! at Request._callback (/opt/node0610/lib/node_modules/npm/lib/utils/npm-registry-client/request.js:137:18)
npm ERR! at Request.callback (/opt/node0610/lib/node_modules/npm/node_modules/request/main.js:109:22)
npm ERR! at Request.<anonymous> (/opt/node0610/lib/node_modules/npm/node_modules/request/main.js:198:58)
npm ERR! at Request.emit (events.js:88:20)
npm ERR! at ClientRequest.<anonymous> (/opt/node0610/lib/node_modules/npm/node_modules/request/main.js:195:10)
npm ERR! at ClientRequest.emit (events.js:67:17)
npm ERR! at CleartextStream.<anonymous> (http.js:1134:11)
npm ERR! at CleartextStream.emit (events.js:67:17)
npm ERR! You may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR!
npm ERR! System Linux 2.6.18-194.el5
npm ERR! command "node" "/opt/node0610/bin/npm" "install" "socket.io"
npm ERR! cwd /opt/node0610/lib/node_modules
npm ERR! node -v v0.6.10
npm ERR! npm -v 1.1.0-3
npm ERR! message failed to fetch from registry: socket.io
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /opt/node0610/lib/node_modules/npm-debug.log
npm not ok
My NPM Version is :
[applmgr#dev node_modules]$ npm --version
1.1.0-3
My NodeJS Version is :
[applmgr#dev node_modules]$ node --version
v0.6.10
I had this issue with npm v1.1.4 (and node v0.6.12), which are the Ubuntu 12.04 repository versions.
It looks like that version of npm isn't supported any more, updating node (and npm with it) resolved the issue.
First, uninstall the outdated version (optional, but I think this fixed an issue I was having with global modules not being pathed in).
sudo apt-get purge nodejs npm
Then enable nodesource's repo and install:
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
Note - the previous advice was to use Chris Lea's repo, he's now migrated that to nodesource, see:
https://chrislea.com/2014/07/09/joining-forces-nodesource/
https://nodesource.com/blog/chris-lea-joins-forces-with-nodesource
From: here
https://github.com/isaacs/npm/issues/2119
I had to execute the command below:
npm config set registry http://registry.npmjs.org/
However, that will make npm install packages over an insecure HTTP connection. If you can, you should stick with
npm config set registry https://registry.npmjs.org/
instead to install over HTTPS.
I'm on Ubuntu. I used apt-get to install node. Npm was not included in that package, so it had to be installed separately. I assumed that would work, but apparently the npm version in the Ubuntu distribution was outdated.
The node wiki has this instruction:
Obtaining a recent version of Node or installing on older Ubuntu and other apt-based distributions may require a few extra steps. Example install:
sudo apt-get update
sudo apt-get install -y python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
After that, npm was already included and worked perfectly.
For me, it's usually a proxy issue, and I try everything:
npm config set registry http://registry.npmjs.org/
npm config set strict-ssl false
npm config set proxy http://myusername:mypassword#proxy.us.somecompany:8080
npm config set https-proxy http://myusername:mypassword#proxy.us.somecompany:8080
set HTTPS_PROXY=http://myusername:mypassword#proxy.us.somecompany:8080
set HTTP_PROXY=http://myusername:mypassword#proxy.us.somecompany:8080
export HTTPS_PROXY=http://myusername:mypassword#proxy.us.somecompany:8080
export HTTP_PROXY=http://myusername:mypassword#proxy.us.somecompany:8080
export http_proxy=http://myusername:mypassword#proxy.us.somecompany:8080
npm --proxy http://myusername:mypassword#proxy.us.somecompany:8080 \
--without-ssl --insecure -g install
You also need to install software-properties-common for add-apt-repository to work.
so it will be
sudo apt-get purge nodejs npm
sudo apt-get install -y python-software-properties python g++ make software-properties-common
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
One thing that has worked for me with random npm install errors (where the package that errors out is different under different times (but same environment) is to use this:
npm cache clean
And then repeat the process. Then the process seems to go smoother and the real problem and error message will emerge, where you can fix it and then proceed.
This is based on experience of running npm install of a whole bunch of packages under a pretty bare Ubuntu installation inside a Docker instance. Sometimes there are build/make tools missing from the Ubuntu and the npm errors will not show the real problem until you clean the cache for some reason.
This problem is due to the https protocol, which is why the other solution works (by switching to the non-secure protocol).
For me, the best solution was to compile the latest version of node, which includes npm
apt-get purge nodejs npm
git clone https://github.com/nodejs/node ~/local/node
cd ~/local/node
./configure
make
make install
There are now official instructions from joyent (primary nodejs backer). For Ubuntu:
sudo apt-get purge nodejs npm
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
For other unix distributions, osx and windows see the link. Note this will install both node and npm.
The only thing that worked for me on Elementary OS Luna, a Ubuntu Fork. I am on x86 architecture. I tried all the answers here but finally decided to install it from source.
First, make sure its not installed using the package manager:
sudo apt-get purge nodejs npm -y
I went to the download page to lookup the latest source & download it, http://nodejs.org/download/. You can use curl, wget or your browser to get it:
wget http://nodejs.org/dist/v0.10.34/node-v0.10.34.tar.gz
tar -xvf node-v0.10.34.tar.gz
cd node-v0.10.34
./configure
make
sudo make install
The make might take a while. When done, you should have node and npm installed and working in your /usr/local/bin directory which should be already on your path. You should verify where it lives:
which npm node
I also had to change the permissions to get it to work:
sudo chown -R $USER /usr/local
If it didn't work check your path:
echo $PATH
Note that installing it this way, it will not be managed by apt-get package manager. Cheers!
Recently I had this problem after upgrading node.js (and inevitably npm) to the newest version:
> npm --version
< 2.0.0-alpha-5
Note: I didn't ask for an unstable version, I just got it after brew install npm on OSX.
Downgrading npm fixed the problem for me.
The easiest way to install the stable npm is npm install -g npm but it might not work under some circumstances and downgrade of node.js might be needed then.
The below method worked for me, Kudos to github user : midnightcodr
Make sure You remove any nodejs/npm packages already installed.
sudo apt-get purge nodejs
sudo apt-get purge npm
Now Install Node js using the command below( Thanks to midnightcodr on github)
curl -L https://raw.github.com/midnightcodr/rpi_node_install/master/setup.sh | bash -s 0.10.24
Note that you can invoke node with command node and not nodejs.
Once node is installed , Install npm
sudo apt-get install npm
It could be that the npm registry was down at the time or your connection dropped.
Either way you should upgrade node and npm.
I would recommend using nave to manage your node environments.
https://npmjs.org/package/nave
It allows you to easily install versions and quickly jump between them.
for raspberry pi I found and modified a solution I found
here is what I ran
sudo su -
cd /opt
wget http://nodejs.org/dist/v0.10.28/node-v0.10.28-linux-arm-pi.tar.gz
tar xvzf node-v0.10.28-linux-arm-pi.tar.gz
ln -s node-v0.10.28-linux-arm-pi node
chmod a+rw /opt/node/lib/node_modules
chmod a+rw /opt/node/bin
echo 'PATH=$PATH:/opt/node/bin' > /etc/profile.d/node.sh
the only mod I did was change all 10.25 to 10.28 which was the latest linux-arm-pi at the time
#therefromhere's answer is the best one. However Node versions have moved ever onwards and upwards, and the versioning was complicated by the remerge of io.js. Following the steps in his answer, you will end up with Node version 0.10.25 - not the most recent version.
You should still purge any existing node/npm packages with
sudo apt-get purge nodejs npm
and then go and look at the nodesource deb install page at https://github.com/nodesource/distributions#debinstall.
All Node.js versions are listed on the above page with the Linux commands to install them. And these packages will work on both Debian and Ubuntu.
P.S. If you want to run Node v4.4 or higher on Ubuntu Precise or Debian Wheezy, you should review the information about running on older distros.
P.P.S. If your apt-get is failing, the script will not complete (Google references were failing my apt-get update). You should see messages about the NodeSource signing key being added to your keyring and a final message instructing you to Run 'apt-get install nodejs' to install Node.js.
P.P.P.S. npm is installed with node. Once installed, you can update to the latest npm with sudo npm install npm -g
For people having this issue from a company network which implement a security system that use a mitm for https traffic, you can configure npm to use your company certificate.
npm config set cafile 'path/to/certif-file'
See https://docs.npmjs.com/cli/v9/using-npm/config#cafile
But don't use configs like strict-ssl=false or setting the registry to http://. This is not a secure way of working.

Resources