npm install puppeteer showing permission denied errors

前端 未结 3 1245
北荒
北荒 2021-01-05 17:55

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

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-05 18:37

    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
    

提交回复
热议问题