fazega
fazega

Reputation: 317

Angular2 change node_modules path

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 ?

Upvotes: 5

Views: 4832

Answers (1)

Hendrik Brummermann
Hendrik Brummermann

Reputation: 8312

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.

Upvotes: 7

Related Questions