Performance Audit Matomo plugin activation fails with NPM & NodeJS errors
-
I am trying to install the PerformanceAudit plugin with Matomo and upon activating it fails with the following error output in the webpage:
PerformanceAudit plugin activation failed due to the following error: Node.js dependency installation failed due to the following error: NPM has the following unexpected output: npm WARN config only Use `--omit=dev` to omit dev dependencies from the install.npm WARN using --force Recommended protections disabled.npm WARN logfile Error: ENOENT: no such file or directory, scandir '/var/www/.npm/_logs'npm WARN logfile at async Object.readdir (node:internal/fs/promises:945:18)npm WARN logfile at async #cleanLogs (/usr/local/node-20.13.1/lib/node_modules/npm/lib/utils/log-file.js:207:19)npm WARN logfile error cleaning log files Error: ENOENT: no such file or directory, scandir '/var/www/.npm/_logs'npm WARN logfile at async Object.readdir (node:internal/fs/promises:945:18)npm WARN logfile at async #cleanLogs (/usr/local/node-20.13.1/lib/node_modules/npm/lib/utils/log-file.js:207:19) {npm WARN logfile errno: -2,npm WARN logfile code: 'ENOENT',npm WARN logfile syscall: 'scandir',npm WARN logfile path: '/var/www/.npm/_logs'npm WARN logfile }npm notice npm notice New minor version of npm available! 10.5.2 -> 10.9.2npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.9.2>npm notice Run `npm install -g npm@10.9.2` to update!npm notice npm ERR! code ENOENTnpm ERR! syscall mkdirnpm ERR! path /var/www/.npmnpm ERR! errno -2npm ERR! enoent ENOENT: no such file or directory, mkdir '/var/www/.npm'npm ERR! enoent This is related to npm not being able to find a file.npm ERR! enoent npm ERR! Log files were not written due to an error writing to the directory: /var/www/.npm/_logsnpm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
And then when returning to Matomo, it shows these two errors in alert style divs:
ERROR: /app/data/plugins/PerformanceAudit/NodeDependencyInstaller.php(147): NPM has the following unexpected output: npm WARN config only Use `--omit=dev` to omit dev dependencies from the install. npm WARN using --force Recommended protections disabled. npm WARN logfile Error: ENOENT: no such file or directory, scandir '/var/www/.npm/_logs' npm WARN logfile at async Object.readdir (node:internal/fs/promises:945:18) npm WARN logfile at async #cleanLogs (/usr/local/node-20.13.1/lib/node_modules/npm/lib/uti (Module: CorePluginsAdmin, Action: activate, In CLI mode: false)
ERROR: /app/data/plugins/PerformanceAudit/NodeDependencyInstaller.php(41): Node.js dependency installation failed due to the following error: NPM has the following unexpected output: npm WARN config only Use `--omit=dev` to omit dev dependencies from the install. npm WARN using --force Recommended protections disabled. npm WARN logfile Error: ENOENT: no such file or directory, scandir '/var/www/.npm/_logs' npm WARN logfile at async Object.readdir (node:internal/fs/promises:945:18) npm WARN logfile at asy (Module: CorePluginsAdmin, Action: activate, In CLI mode: false)
Is this reproducible for anyone else? Is this possible to install with the way Cloudron runs the Matomo package or do we need to make image adjustments?
-
Kinda strange that it wants to run
npm
here in the first place. Matomo is a php app, so presumably the plugins would not require node modules unless they are basically built from source (including web dependency downloading) on the server.The main issue is, that npm wants to write log files into read-only locations. Is this specific to that one plugin or a generic pattern? Also you could maybe try to build the plugin locally and then upload it to matomo?