npm install -g typescript #TODO: verify if that's a good approach
npm install
npm start
- When I change app.ts, the typescript compiler generate build/app.js
- The command
npm link
allow me to run the program as a script from any location on my laptop with the commandsite
. The location of the js file is /home/oren/.nvm/versions/node/v18.18.0/bin/site - The template.html file is located in the 'build' folder
In order to run this program as a linux script, in ./app.js I added the first line: #!/usr/bin/env node.
- In order to call the script with
site
instead of ./app.js I have an entry in package.json called bin. This only worked after I also run the commandnpm link
which allow me to call my program anywhere on my laptop. - In order to unlink, run
npm unlink website-ts
.
I use nodemon and concurrently locally. They can also installed with globally (with -g).
npx ts-node ~/scripts/site-generator.ts
. npx is a shortcut for npm exec, which runs scripts from packages, and ts-node is a wrapper for node that compiles and runs ts as a single step; it's essentially tsc and node in a single command
- Find out if template.html can be in the src instead of build folder.
- Currently the css file is external. Try to use a local file instead.