Role of the src and dist folders in NPM packages


Im using Restangular for HTTP requests. I want to use the method customPATCH. I can see it in the Restangular src/ directory here.

However when I ran ‘npm install restangular’ and pointed to the dist/ folder, I was getting the error “customPATCH is not a function”. I noticed the source code in the dist/ folder isnt the same as what’s in the src/ folder (it doesnt define the customPATCH method).

Why would there be a difference between what’s in src/ and what’s in dist/ for an NPM package? Are these normally kept in sync? In this case, the dist/ directory hasn’t been updated in 8 months. Should I just use the source in the src/ folder? Maybe I’m misunderstanding how to use NPM packages (I always use the source in the dist/ folder)…


src/ and dist/ is a common naming convention for most packages. In most instances a developer has the code that they are working on src/ and the distribution version of the code they want others to use dist/. Most developers, my self included will either compile, minify or concatenate their code in to production facing version of the code. They usually include the src/ file in their public repositories so that people can see the source code and modify it as they see fit.


src/is the code the developer is working in.

dist/ is the distribution version that has been modified to perform better for users not looking to modify how the code works.

Answered By – DominicValenciana

Answer Checked By – Mary Flores (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.