node
, npm
and yarn
tasksGet node
and yarn
installed
If you'd like to do this on your own computer follow the instructions here.
Otherwise you can use repl.it
Run
mkdir project
cd project
yarn init
yarn init
will ask you lots of questions, you can either type your answer to each question and press 'enter', or just press 'enter' multiple times to accept the defaults.
yarn add lodash
import
on nodeModify the package.json
by adding the following key value pair at anywhere at the top level of the JSON object:
"type": "module",
This allows you to use import statements.
random.js
inside the project/
folderimport
the lodash module as _
.
and then: console.log(_.random(100))
which logs a random number between 0 and 100.
Then run your program using node random.js
yarn add prettier --dev
package.json
.Add a script "format"
in your package.json
which calls: prettier --write random.js
Then call your script using yarn run format