Permission denied while trying to install opencv4nodejs in Ubuntu

后端 未结 2 409
情书的邮戳
情书的邮戳 2021-01-26 09:36

I was trying to install opencv4nodejs in Ubuntu-20.04 using the following command and my node version is v12.19.0

sudo npm          


        
相关标签:
2条回答
  • 2021-01-26 10:13

    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

    0 讨论(0)
  • 2021-01-26 10:17

    1.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.

    1. Also make sure you have permission to write to the directory you're installing in?

    2. If it still doesn't work plz follow this : sudo npm install -g opencv4nodejs --unsafe-perm=true --allow-root

    0 讨论(0)
提交回复
热议问题