The problem appears to be inconsistency with root
and user
installed node (v.19.7.0)
, nvm (0.39.3)
, and npm (v. 9.5.0)
and a specific npm
-installed package called svg-path-interpolator
on an Ubuntu 22.0.4 system. Should node
, nvm
and npm
all be uninstalled and reinstalled as user
, or go through each piecemeal - or is it going to work if everything is left as-is? Perhaps I should note that this is just to get one script to run calculations at the user level, i.e. not for a website to handle lots of web traffic etc.
Background: I have naively tried getting javascript code to run described here. The specific package is called svg-path-interpolator
. There are a number of problems with that project, which led me to scrutinize the installation of node
, nvm
, and npm
- even though simple checks with some simple java scripts e.g. from tutorials or the node website work ok. I think it is good that the version of node
is turning out to be the "right" one, e.g. 19.7.0
.
It appears my approach to install npm
, nvm
, and node
(at least) was also naive. The commands I used, in order (I think), were:
sudo apt install npm
sudo npm install -g svg-path-interpolator
sudo npm install svg-path-interpolator --save
npm install svg-path-interpolator
(AT SOME POINT)
sudo apt install node
(PROBABLY)
Note that npm
was ran first locally, no special permissions. The script I want to run didn't work, so naturally I ran npm
"globally", and naturally, the script didn't work. The help page says In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package.
- and I have read this idea elsewhere - what does that mean, that the CWD is being used somehow?
I also tried the --save
option. From reading further - especially regarding permissions and working directory - it appears this willy-nilly user vs. admin installation is bad. Some evidence on my system is (excerpts) :
ls -ltraF /home/user/package-lock.json
-rw-r--r-- 1 root root 2091 Mar 5 11:46 /home/user/package-lock.json
ls -ltraF ~/node_modules/.package-lock.json
-rw-r--r-- 1 root root 1117 Mar 5 11:46 /home/user/node_modules/.package-lock.json
I also see that svg-path-interpolator
is missing from:
/home/user/.nvm/versions/node/v19.7.0/lib/node_modules/npm/node_modules/
there's also node_modules
in /usr/local/lib
, so it is confusing.
One last clue : in trying to get the original task to work, another error is worrisome (but this might be irrelevant) :
./svgpi.mjs config.json balloons.svg output.json
[Error: ENOENT: no such file or directory, mkdir ''] {
errno: -2,
code: 'ENOENT',
syscall: 'mkdir',
path: ''
}
To solve that, I might have run the script with sudo
once to see what would happen, but it seemed not to do anything (I hope).
So perhaps instead of the dreaded complete uninstall and reinstall but-only-as-user, I could leave things be and simply get rid of package-lock.json
and write it out as user
somehow by following the guidance in the npm
or nvm
man pages/web pages or Stack Exchange posts - which I have been following carefully. I tried to cover the bases but again I have a long post because the specific thing to ask about or do is unclear - apologies.