DevDavido / performance-audit-plugin

Daily performance audits of all your sites in Matomo.
GNU General Public License v3.0
12 stars 4 forks source link

Activation failed, because of missing npm dependency #54

Open thebennos opened 7 months ago

thebennos commented 7 months ago

In PerformanceAudit.php line 94:

PerformanceAudit plugin activation failed due to the following error:
Node.js dependency installation failed due to the following error:
npm dependency not found.
Searched in the following directories for the dependency: /var/www/html/plugins/PerformanceAudit/composer/bin, /var/www/html/plugins/PerformanceAudit/node_modules/.bin,
/usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin, /opt/plesk/node/24/bin, /opt/plesk/node/22/bin, /opt/plesk/node/20/bin, /opt/plesk/node/18/bin, /opt/pl
esk/node/16/bin, /opt/plesk/node/14/bin, /opt/plesk/node/12/bin, /opt/plesk/node/10/bin, /home/wodby/.composer/vendor/bin, /var/www/html/vendor/bin, /var/www/html/bin.

I upgraded from Matomo 4 to 5 and tried to enable the module.

DevDavido commented 7 months ago

Hi, have you installed npm on the server where the plugin should be enabled? Is the npm binary located in one of the listed directories from the error message? See whereis npm to list the directory.

shAd09 commented 1 month ago

Hello, i have the same issue.

Debian Bookworm (everything updated) Matomo-Version: 5.1.0 MySQL-Version: 10.11.4-MariaDB-1~deb12u1-log PHP-Version: 8.2.20 Nginx 1.22.1 PHP 8,2-fpm which npm = /usr/local/bin/npm (/usr/local/bin/ is in openbase_dir) npm -v = 6.14.8 /usr/local/bin: npm is a link to: /usr/local/lib/node_modules/npm/bin/npm-cli.js also i added /usr/local/lib/node_modules/npm/bin to my openbasedir, but no succcess. When i replace npm with a placeholder file with same name directly in /usr/local/bin i get another error message. So the npm in /usr/local/bin is executed. Has it to do with the link to ../lib..node_modules...? its a default apt-get debian npm version.

also installed the chrome dependencies ca-certificates fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils

error message: PerformanceAudit plugin activation failed due to the following error: Node.js dependency installation failed due to the following error: npm dependency not found. Searched in the following directories for the dependency: /var/www/matomo/plugins/PerformanceAudit/composer/bin, /var/www/matomo/plugins/PerformanceAudit/node_modules/.bin, /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin, /opt/plesk/node/24/bin, /opt/plesk/node/22/bin, /opt/plesk/node/20/bin, /opt/plesk/node/18/bin, /opt/plesk/node/16/bin, /opt/plesk/node/14/bin, /opt/plesk/node/12/bin, /opt/plesk/node/10/bin. Please disable

I would be very happy to have any suggestions on how to get it to work

Best regards Sebastian

DevDavido commented 1 month ago

Could you temporarily disable open_basedir to check if the problem is related to it? While open_basedir is disabled, you should not see "Please disable PHP open_basedir [...]" as part of the error message then.

shAd09 commented 1 month ago

Could you temporarily disable open_basedir to check if the problem is related to it? While open_basedir is disabled, you should not see "Please disable PHP open_basedir [...]" as part of the error message then.

yeah, worked! After installing i activated my open_basedir restrictions again (with /usr/local/bin in it). In the plugin there was the same error message again.

it seams the reason is:

default debian npm is a link to: /usr/local/lib/node_modules/npm/bin/npm-cli.js

so i added /usr/local/lib/node_modules/npm/bin to my open_basedir directories. Error message is gone now. open_basedir restrictions does not follow symlinks (on debian). learned something again :-)

ok but when i try to start the plugin i get this error messsage: [debug] Debug mode enabled [info] Database timeout configuration: [{"Variable_name":"connect_timeout","Value":"10"},{"Variable_name":"deadlock_timeout_long","Value":"50000000"},{"Variable_name":"deadlock_timeout_short","Value":"10000"},{"Variable_name":"delayed_insert_timeout","Value":"300"},{"Variable_name":"idle_readonly_transaction_timeout","Value":"0"},{"Variable_name":"idle_transaction_timeout","Value":"0"},{"Variable_name":"idle_write_transaction_timeout","Value":"0"},{"Variable_name":"innodb_flush_log_at_timeout","Value":"1"},{"Variable_name":"innodb_lock_wait_timeout","Value":"50"},{"Variable_name":"innodb_rollback_on_timeout","Value":"OFF"},{"Variable_name":"interactive_timeout","Value":"604800"},{"Variable_name":"lock_wait_timeout","Value":"86400"},{"Variable_name":"net_read_timeout","Value":"30"},{"Variable_name":"net_write_timeout","Value":"60"},{"Variable_name":"rpl_semi_sync_master_timeout","Value":"10000"},{"Variable_name":"rpl_semi_sync_slave_kill_conn_timeout","Value":"5"},{"Variable_name":"slave_net_timeout","Value":"60"},{"Variable_name":"thread_pool_idle_timeout","Value":"60"},{"Variable_name":"wait_timeout","Value":"604800"}] [info] Performance Audit task for site 1 will be started now (microtime: 0.67728900 1722593422) [debug] Performing audit for (site ID, URLs, URL count, emulated devices, runs): [1,["https://xxxxx"],1,["mobile"],[1]] [info] Performing scheduled audit [1/1] of site 1 (device: mobile) for URL: https://xxxxxx **[error] Audit of https://xxxxxx failed: Unable to connect to Chrome** [debug] Audit file count: 0 [info] Performance Audit task for site 1 has finished

best regards Sebastian

shAd09 commented 1 month ago

https://itslinuxguide.com/install-google-chrome-debian-12/

I have now installed google chrome manuel (via apt, google repository). However, still the same error message. What am I doing wrong?

DevDavido commented 1 month ago

This plugin does uses Lighthouse with a Google Chrome Headless under the hood. That's why the plugin should handle its installation including all its dependencies, as it does various functionality checks during the installation. I would first try to get it work fully without open_basedir / additionally check the required dependencies for Chrome itself are available (https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#chrome-doesnt-launch-on-linux).