出现错误:chromedriver安装失败,错误eacces权限被拒绝mkdir

时间:2019-10-23 06:06:41

标签: node.js selenium-webdriver mocha selenium-chromedriver node-modules

当我尝试使用节点js安装Chrome驱动程序// A5.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <cmath> #include <iostream> #include <string> #include <fstream> #include <vector> #include <array> using namespace std; int main() { struct Pixel { int Red; int Green; int Blue; }; vector <vector< Pixel> > image; string fileType; int height{}, width{}, maxColor{}; string p3; cout << "Enter the name of the file:"; cin >> fileType; string fileTypeActual = fileType + ".ppm"; ifstream myImage(fileTypeActual); if (myImage.fail()) { cerr << "Fail"; return 1; } while (!myImage.eof()) { string p3; myImage >> p3 >> width >> height >> maxColor; int i, j; for (i = 0; i < height; i++) { vector<Pixel>rowofPixels; for (j = 0; j < width; j++) { Pixel p; myImage >> p.Red; myImage >> p.Green; myImage >> p.Blue; rowofPixels.push_back(p); } image.push_back(rowofPixels); } }; myImage.close(); int userChoice; cout << "Would you like to invert the colors or convert to greyscale? Type 1 for greyscale and 2 for color inversion"; cin >> userChoice; if (userChoice == 1) { //begin greyscale conversion string fileGray; fileGray = fileType + "_grayscale.ppm"; ofstream imageOut(fileGray); if (imageOut.fail()) { cerr << "Fail"; return 1; } struct greyPixel { double redGrey; double blueGrey; double greenGrey; }; vector <vector< greyPixel > > greyScale; //gray = 0.2989 * Red + 0.5870 * Green + 0.1140 * Blue for (int i = 0; i < height; i++) { vector<greyPixel>rowofGrey; for (int j = 0; j < width; j++) { int pixelRed = ((image.at(i)).at(j)).Red; int pixelBlue = ((image.at(i)).at(j)).Blue; int pixelGreen = ((image.at(i)).at(j)).Green; greyPixel g; g.redGrey = 0.2989 * pixelRed + 0.5870 * pixelGreen + 0.1140 * pixelBlue; g.blueGrey = 0.2989 * pixelRed + 0.5870 * pixelGreen + 0.1140 * pixelBlue; g.greenGrey = 0.2989 * pixelRed + 0.5870 * pixelGreen + 0.1140 * pixelBlue; rowofGrey.push_back(g); } greyScale.push_back(rowofGrey); } imageOut.close(); } else if (userChoice == 2) { //begin color inverson string fileInvert; fileInvert = fileType + "_inverted.ppm"; ofstream imageInv(fileInvert); if (imageInv.fail()) { cerr << "Fail"; return 1; } struct invertPixel { int redInvert; int blueInvert; int greenInvert; }; vector <vector< invertPixel > > invert; for (int i = 0; i < height; i++) { vector<invertPixel>rowofInvert; for (int j = 0; j < width; j++) { int pixelRed = ((image.at(i)).at(j)).Red; int pixelBlue = ((image.at(i)).at(j)).Blue; int pixelGreen = ((image.at(i)).at(j)).Green; invertPixel inv; inv.blueInvert = maxColor - pixelBlue; inv.greenInvert = maxColor - pixelGreen; inv.redInvert = maxColor - pixelRed; rowofInvert.push_back(inv); } invert.push_back(rowofInvert); } imageInv.close(); } return 0; } 时,出现此错误:npm install chromedriver --chromedriver-force-download

我已申请chromedriver installation failed error eacces permission denied mkdir的完全许可,但仍收到此错误,有人可以帮助我为什么得到此错误吗?

我使用了以下命令:

777

2 个答案:

答案 0 :(得分:1)

尝试使用sudo关键字

 1)sudo npm i chromedriver

2) Force Download :sudo npm install chromedriver --chromedriver-force-download

答案 1 :(得分:1)

这个在 Ubuntu 20.04 上对我有用

sudo npm -g install chromedriver --unsafe-perm=true --allow-root