Next I could install canvas (using the pi user, starting /home/pi folder):
npm install canvas
After the above 2 steps chart-image has installed from the Palette Manager in Node-Red.
Your example is working now.
Let me ask a related question: if I want to create a small graphics for example show a measurement value, maybe influence the colour based on the value, add trending icon or something similar and send that over telegram as an image. Since I have canvas installed, I could just create a canvas object and save the result to an image similarly like it is done for the canvas image, right?
I tried the above solution, and I had a lot less errors, but still have some as you can see in the log,
>
>
> 2022-12-02T15:35:35.205Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production --engine-strict node-red-contrib-chart-image@1.2.0
>
> 2022-12-02T15:35:37.701Z [err] npm
>
> 2022-12-02T15:35:37.703Z [err]
>
> 2022-12-02T15:35:37.703Z [err] WARN config production Use `--omit=dev` instead.
>
> 2022-12-02T15:35:45.077Z [err] npm ERR! code EACCES
>
> 2022-12-02T15:35:45.077Z [err] npm ERR! syscall rename
>
> 2022-12-02T15:35:45.077Z [err] npm ERR! path /home/pi/.node-red/node_modules/node-gyp/node_modules/.bin/semver
>
> 2022-12-02T15:35:45.077Z [err] npm ERR! dest /home/pi/.node-red/node_modules/node-gyp/node_modules/.bin/.semver-S9LLPkuk
>
> 2022-12-02T15:35:45.078Z [err] npm ERR!
>
> 2022-12-02T15:35:45.079Z [err] errno -13
>
> 2022-12-02T15:35:45.087Z [err] npm ERR! Error: EACCES: permission denied, rename '/home/pi/.node-red/node_modules/node-gyp/node_modules/.bin/semver' -> '/home/pi/.node-red/node_modules/node-gyp/node_modules/.bin/.semver-S9LLPkuk'
>
> 2022-12-02T15:35:45.087Z [err] npm ERR! [Error: EACCES: permission denied, rename '/home/pi/.node-red/node_modules/node-gyp/node_modules/.bin/semver' -> '/home/pi/.node-red/node_modules/node-gyp/node_modules/.bin/.semver-S9LLPkuk'] {
>
> 2022-12-02T15:35:45.087Z [err] npm ERR! errno: -13,
>
> 2022-12-02T15:35:45.099Z [err] npm ERR! code: 'EACCES',
>
> 2022-12-02T15:35:45.099Z [err] npm ERR! syscall: 'rename',
>
> 2022-12-02T15:35:45.099Z [err] npm ERR! path: '/home/pi/.node-red/node_modules/node-gyp/node_modules/.bin/semver',
>
> 2022-12-02T15:35:45.099Z [err] npm ERR! dest: '/home/pi/.node-red/node_modules/node-gyp/node_modules/.bin/.semver-S9LLPkuk'
>
> 2022-12-02T15:35:45.099Z [err] npm ERR! }
>
> 2022-12-02T15:35:45.099Z [err] npm ERR!
>
> 2022-12-02T15:35:45.099Z [err] npm ERR! The operation was rejected by your operating system.
>
> 2022-12-02T15:35:45.099Z [err] npm ERR! It is likely you do not have the permissions to access this file as the current user
>
> 2022-12-02T15:35:45.099Z [err] npm ERR!
>
> 2022-12-02T15:35:45.099Z [err] npm ERR! If you believe this might be a permissions issue, please double-check the
>
> 2022-12-02T15:35:45.099Z [err] npm ERR! permissions of the file and its containing directories, or try running
>
> 2022-12-02T15:35:45.099Z [err] npm ERR! the command again as root/Administrator.
>
> 2022-12-02T15:35:45.107Z [err]
>
> 2022-12-02T15:35:45.107Z [err] npm ERR! A complete log of this run can be found in:
>
> 2022-12-02T15:35:45.107Z [err] npm ERR! /home/pi/.npm/_logs/2022-12-02T15_35_37_574Z-debug-0.log
>
> 2022-12-02T15:35:45.132Z rc=243
Never use sudo unless you know that it is what you should do. You may now have created some files in your home folder with root permissions, which will cause different problems. We will have to sort those problems out if they appear.
npm seems to get itself in a mess sometimes, it is not clear why.
Rename the directory /home/pi/.node-red/node_modules to something else (just in case we want to look at it again. Then go into the .node-red folder and run npm install
which should rebuild it. It might take a little while depending on what sort of pi it is.
What do these commands show npm -v node -v
@dceejay@knolleary this problem seems to be occurring more and more often. Do we have any clues about what the underlying cause is?
That is a bit odd. Do you remember how you installed nodejs and npm? The default install of nodejs includes npm, and I have npm 8.19.2 with nodejs 16.18.1
That is interesting, I wonder if you have ended up with an npm that is not compatible with the nodejs you have. It may be nothing to do with that though.