To use our mirror simply change your local npm config to point at our registry:
npm config set registry https://dccmzgc64kzf2.cloudfront.net/
npm config set ca ""
Our mirror only supports a subset of what the real NPM can do. Specifically you can:
npm info <package-name>
npm install <package-name>
To revert back to the original NPM registry, you can delete your local npm config changes:
npm config delete registry
npm config delete ca
If you run into any issues with our mirror, please file a bug. Thanks!
Finally, if you've found Mozilla's mirror useful, you should consider donating to Mozilla. Contributions go to the Mozilla Foundation, a 501(c)(3) organization, to be used in its discretion for its charitable purposes. They are tax-deductible in the U.S. to the fullest extent permitted by law.
To run your own mirror, you'll need to sign up for an AWS account.
Once you've done that fetch this repository and its dependencies:
git clone https://github.com/jbuck/npm-readonly-mirror.git
cd npm-readonly-mirror
npm install
- Create a new S3 bucket. If you're not sure how, Amazon has some documentation. Remember the bucket name and region you created it in.
- View your bucket properties by clicking its name in the bucket list, and then clicking the properties button on the top right of the console.
- Change the default permissions for your bucket to allow for anonymous GET Object requests. Click the Permissions tab, then the Add bucket policy button. Add the following policy, with the Resource name changed to match yours:
{
"Version": "2008-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::<your-bucket-name>/*"
}
]
}
- Make your S3 bucket available as a static website. Click the Static Website Hosting tab then the Enable website hosting radio button. Change the Index Document to be "_index" and the Error Document to be "_error".
- Upload a file named
_index
with the content:{"update_seq":0}
- Upload a file named
_error
with the content:{"error":"not_found","reason":"missing"}
- Create a new CloudFront distribution with the following settings
Origin Domain Name
should be your S3 static website URLViewer Protocol Policy
should beHTTPS Only
- You should change the Cache settings so that the tarballs are cached for a long time (a whole year?) and the package metadata files are updated more frequently.
cp dist.json local.json
- Edit
local.json
:
- Modify the sink registry to match your AWS S3 static website URL
- Modify the sink package_host to match your AWS CloudFront URL
- Modify the s3 bucket, key and secret to match your AWS information
- You can't install the
soap
package. This is an Amazon S3 bug with their SOAP API and me not working around it by using path-style operations.