Node Setup

From CSE256A Wiki
Jump to navigation Jump to search
  1. If you do not have Node.js installed yet, follow the link to install it before proceeding.
    1. After installing Node.js and setting up your path variables, run the following commands via a terminal window to test that your installation is an up-to-date version.
      1. Run the command 'node -v', which displays the node version, and you should get output similar to 12.14.1
      2. Run the command 'npm -v', which displays the npm version, and you should get output similar to 6.13.4. npm stands for Node Package Manager and is used to manage dependencies for your projects.
      3. At this point you have Node.js and the Node Package Manager (npm). You will use these to install the necessary dependencies as well as transpile and bundle TypeScript files into JavaScript files that will be used to facilitate dynamic HTML and data collection.
  2. As is stated in the previous point TypesSript will be used to develop dynamic code for this course. In order to run TypeScript in the browser, it must be transpiled to JavaScript and to be efficient it must also be bundled into a single file. To facilitate this, a popular tool called Browserify will be used. To make sure that this tool runs smoothly, all dependencies must be installed.
  3. To install all necessary dependencies do the steps below.
    1. In a terminal or powershell window, navigate to your repository for CSE 256
    2. Next navigate to <your-repo-path>/projects/core
    3. Once here, install all dependencies locally for the core package (which is necessary for your project to run properly) by running this command: npm install
    4. Next, navigate to <your-repo-path>/projects/information-foraging
    5. Once here, once again run: npm install
    6. At this point all necessary dependencies have been installed. As more projects are distributed throughout the semester the same steps need to be followed to install dependencies for new projects as well.
  4. Now that all dependencies have been installed a single build script can be run that will transpile and bundle all TypeScript for your projects. The script will watch for changes to TypeScript files and recompile when new changes are saved to your filesystem. Every time that a recompilation finishes the time will be printed to the terminal window, therefore if you are ever curious if a recompilation has happened since your most recent changes just check the timestamp.
  5. To run the build script:
    1. In a terminal or powershell window navigate to your repository for CSE 256
    2. Next navigate to <your-repo-path>/projects/<project-you-are-working-on>, which is the location that you can run the build script from
    3. Use one of the two build script options:
      1. To run once, run this command: npm run-script build
      2. To continually watch for changes, run this command: npm run-script watch