You can try the following;
1. Customize and Install Packages: Initially install and customize your packages as needed.
2. Generate npm-shrinkwrap.json: Run npm shrinkwrap in your project directory. This command creates an npm-shrinkwrap.json file which locks down the versions of all installed packages and their dependencies.
3. Edit npm-shrinkwrap.json: In the npm-shrinkwrap.json, you can manually edit the entries for your customized packages to point to your specific versions or local copies. This way, whenever npm install runs, it respects the versions and sources specified in the npm-shrinkwrap.json, ignoring any updates or changes that would normally be fetched from the npm registry.
If that doesn't work, try with local paths:
Leveraging package-lock.json with Local Paths
1. Install Custom Packages Locally: Place your customized packages in a known directory within your project or somewhere accessible to your project.
2. Modify package.json: Reference these local packages in your package.json by specifying their paths instead of version numbers.
3.Commit package-lock.json: After running npm install, ensure that your package-lock.json is updated and commit this file to your repository. The package-lock.json ensures that the exact structure of your node_modules directory is replicated on future installations, including the use of local packages.
I would advise to use the first to methodes, if that doesn't work you can go and override packages.
Using .npmrc for Overriding Package Locations
Configure .npmrc: You can use an .npmrc file to override the source location of specific packages. This is a bit more advanced and typically used to switch between different registries, but you can specify local paths or custom URLs for your packages.
However, this approach requires that your packages are structured and can be installed in a manner similar to those hosted on npm registries, which might involve additional setup for your custom packages.