Open krmax44 opened 5 years ago
The install script of hafas-client
(a transitive dependency of db-cli
) generates a unique ID and tries to write it to id.json
, which apparently it doesn't have write access to.
Can you install other dependencies globally?
Yes, other packages install just fine. :no_mouth:
Hm. My assumption is that the install script isn't being run as the same user or with the same privileges as the npm
process itself.
To investigate this further, running with npm i -g --ignore-scripts db-cli
should work fine (but yield a non-functional installation).
ping 😉 What does npm i -g --ignore-scripts db-cli
give you?
sudo npm i -g --ignore-scripts db-cli
outputs:
/usr/bin/db-dep -> /usr/lib/node_modules/db-cli/dep.js
/usr/bin/db-journey -> /usr/lib/node_modules/db-cli/journey.js
+ db-cli@1.1.1
added 164 packages from 71 contributors in 8.435s
Does it yield a functional install? It shouldn't. Please run db-dep
and type a station name to check.
No, as expected it says Failed to load the install-unique ID from /usr/lib/node_modules/db-cli/node_modules/hafas-client/id.json.
Okay, this indeed an npm permission issue. I could npm install -g
a package with an install
script that writes a file. The script ran as my local user.
I ran into the same problem. sudo npm i -g --ignore-scripts db-cli
and then writing the output of node /usr/local/lib/node_modules/db-cli/node_modules/hafas-client/lib/generate-install-id.js
into /usr/local/lib/node_modules/db-cli/node_modules/hafas-client/id.json
worked for me.
@manuels seems like a good workaround for now, will try later!
FYI: There's also this guide on how to move the global installation path to ~/.npm-global
.
The changes in public-transport/hafas-client#124 have been merged and published as hafas-client@4.5.2
. This problem should be fixed with a fresh install of db-hafas
.
When installing via
sudo npm i -g db-cli
, this error shows up:It does work with
sudo yarn global add db-cli
. :thinking: