pouchdb-server - Install without sqlite3 - node.js

I am trying to install pouchdb-server as shown below:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs build-essential
sudo npm install -g pouchdb-server
The installation is stuck in an infinite loop with sqlite3. The following message appears repeatedly.
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/pouchdb-server/node_modules/sqlite3/.node-gyp"
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/lib/node_modules/pouchdb-server/node_modules/sqlite3/.node-gyp/8.11.1"
How do I get rid of these messages for a successful installation?

The following rids the errors mentioned above.
sudo npm install -g pouchdb-server --ignore-scripts

Related

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 failes with ERR! tar.unpack (raspi)

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

NodeJS installing on Docker

I am trying to run my app on the Docker. One of the library I am using is https://www.npmjs.com/package/odbc.
In order to install that lib I need to meet the requirements described in the odbc readme:
unixODBC binaries and development libraries for module compilation
on Ubuntu/Debian sudo apt-get install unixodbc unixodbc-dev
on RedHat/CentOS sudo yum install unixODBC unixODBC-devel
odbc drivers for target database
properly configured odbc.ini and odbcinst.ini.
As per Microsoft doc in order to install ODBC Driver 13 for SQL Server https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017#ubuntu-1604-1
I manage to install all the stuff locally on my Mac and successfully connect with the SQL Server on Azure but still have some issues with installing them on the Docker and then run on VSTS.
My Dockerfile:
FROM ubuntu:16.04
USER root
RUN apt-get update
RUN apt-get install --yes curl
RUN curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
RUN apt-get install --yes nodejs
RUN apt-get install --yes build-essential
RUN apt-get install -y npm
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get install -y build-essential
RUN apt-get install -y make
RUN apt-get install apt-transport-https
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql unixodbc-dev
ADD . /var/www/app
WORKDIR /var/www/app
RUN npm install && \
npm cache clean --force
RUN npm run build
EXPOSE 3000:80
CMD ["npm", "start"]
But so far have an issue with installing NodeJS in line with
RUN curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
error: /bin/sh: 1: sudo: not found
I was trying to install only the driver and for installing NodeJs just use some existing Docker images:
FROM ubuntu:16.04
USER root
RUN apt-get update
RUN apt-get install --yes curl
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get install -y build-essential
RUN apt-get install -y make
RUN apt-get install apt-transport-https
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql unixodbc-dev
FROM node:9-alpine
ADD . /var/www/app
WORKDIR /var/www/app
RUN npm install && \
npm cache clean --force
RUN npm run build
EXPOSE 3000:80
But that approach throws an error:
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:483:19)
gyp ERR! stack at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:397:16)
gyp ERR! stack at F (/usr/local/lib/node_modules/npm/node_modules/which/which.js:68:16)
gyp ERR! stack at E (/usr/local/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/which/node_modules/isexe/index.js:42:5
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/which/node_modules/isexe/mode.js:8:5
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:170:21)
gyp ERR! System Linux 4.9.125-linuxkit
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /var/www/app/node_modules/odbc
gyp ERR! node -v v9.11.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! odbc#1.4.5 install: `node-gyp configure build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the odbc#1.4.5 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/2019-03-08T20_51_17_496Z-debug.log
You are working off the ubuntu:16.04 image, and essentially doing a lot of footwork that the NodeJS guys have already done.
I would go for the image node:10-stretch-slim if I was you. And then install the drivers that you need with apt-get (if available, otherwise script the download and install in your Dockerfile).
The sudo command is not typically installed on docker images, because the user is root by default in the container sessions. If you see any errors concerning sudo, you can generally just remove sudo from the command line that is causing the issue.
Possible solution
Updating my answer here, with a possible solution for you.
This solution will put your application in a node 10 image, based on debian stretch 9. It will get the database drivers for you, from the debian 9 microsoft repository, and install all the packages that I see you are requiring from your question.
I have also added an ENTRYPOINT and CMD in the bottom of the script. But those lines are guesswork, since your question states nothing about how you actually start your application. (If you add that, then I will update my answer).
Note. Notice that I am passing --host 0.0.0.0 to the npm run start command. This is to avoid binding the live server to localhost, which will make in inaccessible from outside the container. Unless you start the container with --network="host".
You may have another means of starting your application that is more "production grade" than the live development server. If so, just replace the lines in the bottom of the Dockerfile, or ask me on this answer.
Dockerfile
# from debian stretch 9.8, node 10
FROM node:10-stretch-slim
# get apt-transport-https, etc., so that we can install by https protocol
RUN apt-get update \
&& apt-get install -y \
apt-transport-https \
build-essential \
make
# add and accept the microsoft signature
RUN curl -q https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
# retrieve the microsoft packagelist for debian 9
RUN curl -q https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
# install the ms odbc sql driver and unixodbc header stuff
RUN apt-get update \
&& ACCEPT_EULA=Y apt-get install -y \
msodbcsql17 \
unixodbc-dev \
&& rm -rf /var/lib/apt/lists
# expose port 80 in containers of this image
EXPOSE 80
# copy working directory into the image and set as pwd
ADD . /var/www/app
WORKDIR /var/www/app
# install dependencies for the application
RUN npm install \
&& npm cache clean --force
# build the application
RUN npm run build
# i am just guessing how you want your app started here, npm?
ENTRYPOINT ["npm"]
# and then this, which makes "npm run start --host 0.0.0.0"
CMD ["run", "start", "--host", "0.0.0.0"]
Build the image with:
docker build -t mynodeapp:0.1 .
Run the application image with:
docker run -p 3000:80 --name mynodeapp mynodeapp:01
Finally visit: http://localhost:3000 to see it working.

node-red - Installation stuck at gyp for bcrypt

I am running the following commands to install node-red on a AWS EC2 t2.micro instance.
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs build-essential
sudo npm install -g node-red
The installation seems to be in an infinite loop at this point:
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/node-red/node_modules/bcrypt/.node-gyp"
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/lib/node_modules/node-red/node_modules/bcrypt/.node-gyp/8.11.1"
If I hit Ctrl-C and rerun sudo npm install -g node-red then the installation seems to go through successfully. Is this valid behavior?
Try installing with the --unsafe-perm flag.

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.

Resources