A project providing a basic JavaScript REPL (Read-Eval-Print Loop) for local development.
-
Ensure that node has been installed as outlined in JavaScript, Cont., Writing JavaScript Locally.
$ brew install node
-
Fork and clone this project.
-
In your terminal, navigate to the project directory.
-
Install the project dependencies.
$ npm install
-
In your terminal, navigate to the project directory.
-
Open the project in VS Code
$ code .
-
Make edits to the
src/index.js
file. -
Run the REPL.
-
In the terminal from the project directory, run the following command:
$ node src/index.js
Or
$ npm start
-
Or from VS Code, install the Code Runner extension and run the file by clicking the play button in the top right corner of the editor.
- Repeat steps 3-4 as needed.
The project is configured to use ESLint to provide syntax warnings. ESLint can be run from the project directory using the following command:
$ npm run lint
ESLint warnings can be shown in VS Code by installing the ESLint extension.
A simple example test is provided in the src/math.test.js
file, which tests a function defined in src/math.js
. To run the test, use the following command:
$ npm test
Tests can be discovered by VS Code by installing the Jest extension.
Tests will be covered in more detail in Unit 3, Tests
Additional files can be added to the src
directory and then run from the project directory as
$ node src/<filename>.js
Generally, we can run a file by using the command
$ node path/to/file.js
Where path/to/file.js
is the path to the file we want to run relative to the current directory.