Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I install node_modules once, and require all time

Tags:

node.js

Same title.

I don't want install every time with any project.

Just install once.

Thanks in advance.

Edit: I know install global but how to require it is my question.

like image 920
Hongkiat Avatar asked Nov 08 '22 01:11

Hongkiat


1 Answers

Check Addenda: Package Manager Tips Define NODE_PATH with path local modules, example:

  • /usr/lib/node_modules
  • C:\Users\<Username>\AppData\Local\Yarn\Data\global\node_modules
  • Or anywhere you want

And now you can call it.

Since the module lookups using node_modules folders are all relative, and based on the real path of the files making the calls to require(), the packages themselves can be anywhere.

like image 114
hong4rc Avatar answered Nov 15 '22 12:11

hong4rc