geerlingguy / ansible-role-nodejs

Ansible Role - Node.js

Home Page:https://galaxy.ansible.com/geerlingguy/nodejs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Global packages doesn't use nodejs_install_npm_user?

dianomi-mjs opened this issue · comments

Hi

Trying to use this role to install nodejs plus some packages

- {
    role: geerlingguy.nodejs,
    nodejs_install_npm_user: "root",
    nodejs_npm_global_packages: [node-sass, puppeteer]
  }

And getting errors like this

TASK [geerlingguy.nodejs : Ensure npm global packages are installed.] ****************************
task path: /home/mjs/.ansible/roles/geerlingguy.nodejs/tasks/main.yml:26
failed: [hostname] (item=node-sass) => {"changed": false, "cmd": "/bin/npm install --global ''", "item": "node-sass", "msg": "Unable to save binary /usr/local/lib/npm/lib/node_modules/node-sass/vendor/linux-x64-64 :********@4.12.0 postinstall script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /root/.npm/_logs/2019-05-23T09_33_20_090Z-debug.log

Not an expert by any means but there shouldn't be permission errors installing if I'm root. But looking at https://github.com/geerlingguy/ansible-role-nodejs/blob/master/tasks/main.yml it seems perhaps the package installation doesn't use the nodejs_install_npm_user?

I have the same issue on Amazon Linux 2.
I tried either way:

  roles:
    - role: geerlingguy.nodejs
      vars:
        nodejs_version: '8.x'
        npm_config_prefix: '/usr/local/lib/npm'
        nodejs_npm_global_packages: 
          - name: jfrog-cli-go

OR

    - name: Install nodejs packages
      npm:
        name: jfrog-cli-go
        global: yes
        state: latest

Still results in the same error message:

TASK [Install node.js packages] *************************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "cmd": "/usr/bin/npm install --global jfrog-cli-go", "failed": true, "msg": "\n┌───────────────────────────────────────────────────┐\n│              npm update check failed              │\n│        Try running with sudo or get access        │\n│       to the local update config store via        │\n│ sudo chown -R $USER:********@1.25.0 preinstall script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     /root/.npm/_logs/2019-05-24T12_51_37_733Z-debug.log", "rc": 1, "stderr": "\n┌───────────────────────────────────────────────────┐\n│              npm update check failed              │\n│        Try running with sudo or get access        │\n│       to the local update config store via        │\n│ sudo chown -R $USER:$(id -gn $USER) /root/.config │\n└───────────────────────────────────────────────────┘\nevents.js:183\n      throw er; // Unhandled 'error' event\n      ^\n\nError: EACCES: permission denied, open 'bin/jfrog'\nnpm ERR! code ELIFECYCLE\nnpm ERR! errno 1\nnpm ERR! jfrog-cli-go@1.25.0 preinstall: `node init.js`\nnpm ERR! Exit status 1\nnpm ERR! \nnpm ERR! Failed at the jfrog-cli-go@1.25.0 preinstall script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     /root/.npm/_logs/2019-05-24T12_51_37_733Z-debug.log\n", "stderr_lines": ["", "┌───────────────────────────────────────────────────┐", "│              npm update check failed              │", "│        Try running with sudo or get access        │", "│       to the local update config store via        │", "│ sudo chown -R $USER:$(id -gn $USER) /root/.config │", "└───────────────────────────────────────────────────┘", "events.js:183", "      throw er; // Unhandled 'error' event", "      ^", "", "Error: EACCES: permission denied, open 'bin/jfrog'", "npm ERR! code ELIFECYCLE", "npm ERR! errno 1", "npm ERR! jfrog-cli-go@1.25.0 preinstall: `node init.js`", "npm ERR! Exit status 1", "npm ERR! ", "npm ERR! Failed at the jfrog-cli-go@1.25.0 preinstall 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-05-24T12_51_37_733Z-debug.log"], "stdout": "\n> jfrog-cli-go@1.25.0 preinstall /usr/local/lib/npm/lib/node_modules/jfrog-cli-go\n> node init.js\n\nDownloading JFrog CLI 1.25.0\n", "stdout_lines": ["", "> jfrog-cli-go@1.25.0 preinstall /usr/local/lib/npm/lib/node_modules/jfrog-cli-go", "> node init.js", "", "Downloading JFrog CLI 1.25.0"]}

Even trying to use npm manually gives the same permission error:

# npm install -g jfrog-cli-go

> jfrog-cli-go@1.25.0 preinstall /usr/local/lib/npm/lib/node_modules/jfrog-cli-go
> node init.js


┌───────────────────────────────────────────────────┐
│              npm update check failed              │
│        Try running with sudo or get access        │
│       to the local update config store via        │
│ sudo chown -R $USER:$(id -gn $USER) /root/.config │
└───────────────────────────────────────────────────┘
Downloading JFrog CLI 1.25.0
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: EACCES: permission denied, open 'bin/jfrog'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! jfrog-cli-go@1.25.0 preinstall: `node init.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the jfrog-cli-go@1.25.0 preinstall 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-05-24T12_55_07_113Z-debug.log

Seems like Nodejs installation is missing something to allow packages to be installed afterwards.

2019-05-24T12_55_07_113Z-debug.log

The same problem.

Same issue :(

I can confirm this issue

commented

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

commented

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.

Same issue