This code is easy to read, but we need to download the
moment.min.js file every time it updates and manually include it.
node_modules folder, easing the user of the tedious effort of finding and downloading each code file. Also, it creates a
package.json file with a list of dependencies and their versions, making it easy for developers to share the environment in which the code was created. However, still, the user has to manually include the source code with the
<script> tag, which now is located deeper inside the
Node.js made the process of including much easier by introducing the
var moment = require('moment');
index.js file to create a final output
bundle.js compatible with the browser. Now the developer can include the
bundle.js file to
index.html, and the browser works as planned.
packages.json can be used for implementing advanced features. By adding values in the “script” key, we can use the task runner in the npm.
- “build”: Control action during the build, such as minimizing code.
- “server”: Open the
Also, webpack has a configuration file