Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2 change node_modules path

Tags:

angular

I have an Angular2 project and I want to move my node_modules folder to a different location.

Say for example my project is in C:\Users\Me\MyAngularProject and i want my modules to be in C:\node_modules (not the global one by the way).

Where can I set this path in the configuration files of my project ?

like image 441
fazega Avatar asked Oct 18 '22 08:10

fazega


1 Answers

Unfortunately there is no simple configuration setting. Having node_modules outside the current project is considered bad practice. Although there is a number of use cases for it.

You can use a juncture on Windows

mklink /j node_modules C:\node_modules

or a symlink on Linux

ln -s ~/shared_node_modules node_modules

After you have done this, you need to add --preserve-symlinks to ng build and ng serve in order to prevent typescript warnings and include style sheets.

There is a feature request to add --preserve-symlinks to ng test. It seems to work without but there is a huge number of annoying warnings at the moment.

like image 134
Hendrik Brummermann Avatar answered Nov 15 '22 10:11

Hendrik Brummermann