The goal of this activity is to:
- Install the
dayjs
package. - Import the package into a node script.
- Output some fancy dates!
- Command line basics
npm
installed- There is a
package.json
file present in the project root directory. dayjs
is not listed as a dependency inpackage.json
.- See:
npm
getting started.
-
Navigate to your project directory using your terminal.
-
Install the
dayjs
package with the following command:$ npm install dayjs
- Note that you can also use the shorter
npm i dayjs
command.npm i
andnpm install
are the same command. - You will often see examples using the
--save
flag to download packages tonode_modules
. This is now default and no longer needed.
- Note that you can also use the shorter
-
You can now import
dayjs
in your Node application:import dayjs from 'dayjs'
- Note: Not all packages are imported the same way. Check the package's documentation for proper use.
-
Try logging some fancy dates to the console. Checkout the DayJS documentation or search for examples.
See included files for example of use:
now.js
diff.js
mars.js