Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between npm run dev and parcel index.html

I can use parcel index.html to create a local development server, bundling and hot module replacement. But it have come to my attention that using npm run dev does kind of the same think, so my question is:

what is the difference between the two? and how npm run dev is making the bundling process?

like image 980
Mateo Lara Avatar asked Oct 24 '25 03:10

Mateo Lara


1 Answers

NPM vs Parcel isn't a valid comparison. They are two separate things. You can use Parcel with both NPM and Yarn.

Parcel is a web application bundler that is comparable to Webpack

NPM is a package management system for node.

npm run * is a command that will execute any npm script specified within your package.json and has no exclusivity to Parcel. You can of course make an npm script that will execute Parcel commands.

If you go into your package.json file, you will see a scripts property. Within this object, you can define arbitrary scripts to run. There are reserved script names such as start, install, build among others, but for the most part, this is a "free-for-all" that enabled the developer to specify any arbitrary scripts to run. A few common scripts that you'll typically see scripts to bundle your project or run a linter.

Example of package.json

Webpack Example:

{
  "scripts": {
    "build": "webpack --config <your entry file>"
  }
}

Parcel Example:

{
  "scripts": {
    "build": "parcel build <your entry file>"
  }
}
like image 173
mwilson Avatar answered Oct 25 '25 18:10

mwilson