0

To use a node library (uuid) as a command line tool from an other software I'm working on, I installed the library globally by npm i --global uuid and tested the installation by node -e 'console.log(require("uuid")())', but I get an error Error: Cannot find module 'uuid', the global installation apparently not working properly. If I save the library locally, on the directory run the same command, it does work, so the problem is apparently the global installation. What's wrong with this?

$ nvm --version
0.35.3
$ npm -v
6.13.7
$ node -v
v13.10.1
ー PupSoZeyDe ー
  • 1,082
  • 3
  • 14
  • 33
  • Note: I couldn't use the "uuid" library from the command line evaluate using the globally installed path, but using a locally installed path. so like, `cd path/to/a/dir ; export NODE_PATH="$(npm root )"` rather than `export NODE_PATH="$(npm root -g)"`. I assume it's most probably because the particular package "uuid" is different between the versions and/or the installation method, globally or locally. – ー PupSoZeyDe ー May 30 '21 at 05:10

1 Answers1

-1

here is an ref , it can be access rights on mac/linux

https://github.com/sindresorhus/guides/blob/main/npm-global-without-sudo.md

nigam_vaibhav
  • 16
  • 1
  • 1