- Snippet Path
NPM snippets
- Authors
- ← Back to snippet list

- Name
- Aryan Ebrahimpour
- GitHub
- @avestura
- Snippet
Publish all dependencies to a private registry
- Set custom registry using
.npmrc - Install packages online first and generate
package-lock.jsonoryarn.lockfiles. - Parse lock files and
npm publish $RESOLVED_URLfor each package in lock file where$RESOLVED_URLis the resolved url of the package inside the lock file.
powershell
$file = [System.IO.File]::ReadAllText("$(pwd)/yarn.lock")
$matches = ([regex]'resolved "(.*)"').Matches($file)
$matches | % { npm publish $_.Groups[1].Value }
Output list of deps url
powershell
$file = [System.IO.File]::ReadAllText("$(pwd)/yarn.lock")
$matches = ([regex]'resolved "(.*)"').Matches($file)
$paths = $matches | % { $_.Groups[1].Value }
$paths | out-file paths.list
Modify package and gzip+tar it
Sometimes packages have publishConfig inside their package.json file and can't be
easily republished. One workaround is to download the tgz file and remove the publishConfig property.
shell
# extract the archive file ($PACKAGE_NAME.tgz) to $PACKAGE_NAME folder
cd $PACKAGE_NAME
tar -cvzf $PACKAGE_NAME.tgz package
npm publish $PACKAGE_NAME.tgz