I need to replace a file from dependency, located in "node_modules". It is not a good practice to amend node_modules directly, as it will be overwritten with next "npm install". How can I replace such file without touching "node_modules"? For example we can do it with typings. But what about other files?
In my case I want to replace "foo.component.less" and "foo.component.metadata.json" files. Just creating new files in host doesn't help as it would overwrite access to css, but not metadata.
Optimal, but long solution: to create copy/fork of the package's source code:
readme.md
file not to miss in future upgrades.If we don't require to update files and structure entirely, it can be enough to place overriding files to the root of the project(as for Angular
). For example such css
file would override the same one in node_modules
:
npm
will look it first.