A content delivery network or content distribution network (CDN) is a geographically distributed network of proxy servers and their data centers. The goal is to distribute service spatially relative to end-users to provide high availability and high performance. CDNs serve a large portion of the Internet content today, including web objects (text, graphics and scripts), downloadable objects (media files, software, documents), applications (e-commerce, portals), live streaming media, on-demand streaming media, and social networks.

Examples

  • /react@15.3.1/dist/react.min.js
  • /react-dom@15.3.1/dist/react-dom.min.js
  • /history@4.2.0/umd/history.min.js

You may also use a tag or version range instead of a fixed version number, or omit the version/tag entirely to use the latest tag.

  • /react@^0.14/dist/react.min.js
  • /react/dist/react.min.js

If you omit the file path, npm cdn will try to serve the browser bundle if present, the main module otherwise.

  • /jquery
  • /angular-formly
  • /three

Append a / at the end of a URL to view a listing of all the files in a package.

  • /lodash/
  • /modernizr/
  • /react/

Some companies think it's very hard and choose outsourcing custom node.js app development. It's better because you can get a lot of time. Outsouring development is not expensive. Some companies like https://intetics.com/ have a cheap price.

Query Parameters

Name Default Value Description
main npm cdn, browser, main The name of the field in package.json to use as the main entry point when there is no file path in the URL.
json undefined Return a recursive list of metadata about all the files in a directory as JSON (e.g. /any/path/?json). Note: this only works for directories.

Suggested Workflow

For npm package authors, npm cdn relieves the burden of publishing your code to a CDN in addition to the npm registry. All you need to do is include your UMD build in your npm package (not your repo, that's different!).

You can do this easily using the following setup:

  • Add the umd (or dist) directory to your .gitignore file
  • Add the umd directory to your files array in package.json
  • Use a build script to generate your UMD build in the umd directory when you publish

That's it! Now when you npm publish you'll have a version available on npm cdn as well.

Javascript development in our company

© 2017 unpkg