This package demonstrates a simple module example. The sample module contains an exported constant, function, and a class.
- On your local machine, create a new directory.
- cd to your new directory.
- Run
npm initto create apackage.jsonfile. - Add this package using
npm -ioryarn add. - Create a new
index.jsfile. - Add this code:
import { coolNum, hello, dx } from 'coderdx-es-module-example'
console.log('Way cool num: ', coolNum)
hello()
const importedClass = new dx
importedClass.printDay()
- In your shell run
node index.js - In your terminal you should see
$ node index.js
Way cool num: 42
Hello!
The day today is: 29
$