Node.js
March 29, 2023 ยท View on GitHub
- Reference: JavaScript
- https://devcenter.heroku.com/articles/node-best-practices
- https://david-dm.org/zce/itcast-tms?type=dev
- https://github.com/observing/pre-commit
tooling
yarn add -g prettyjson
https://npmcompare.com/compare/jsontool,prettyprint
yarn vs npm
| yarn | npm |
|---|---|
| yarn | npm install |
yarn add package | npm -i -S package |
- https://yarnpkg.com/
- https://www.sitepoint.com/yarn-vs-npm/
- https://yarnpkg.com/lang/en/docs/migrating-from-npm/
- https://shift.infinite.red/npm-vs-yarn-cheat-sheet-8755b092e5cc
ORM
nvm
nvm ls nvm use system
gitignore
node_modules
package.json
Environment variables are passed into the scripts.
This can be tested via:
{
scripts: {
"env": "env | grep NODE"
}
}
Run
yarn run env
NODE_ENV=production yarn run env
express
DEBUG=express:* yarn start
DEBUG=express-start yarn start
DEBUG=knex:* yarn start
DEBUG=knex:query yarn start
DEBUG=knex:tx yarn start
https://github.com/node-inspector/node-inspector
Strings
https://stackoverflow.com/questions/16293923/does-v8-have-unicode-support https://github.com/v8/v8/blob/master/include/v8.h
https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings https://nodejs.org/dist/latest-v4.x/docs/api/buffer.html#buffer_buffers_and_character_encodings
Mocha
mocha -g 'grep patern for function' file
grunt
grunt --tasks .
Bootstrapping a project
- Use Yarn
- Install eslint
- Install flow
- Install pre-commit hooks
brew install yarn
yarn add --dev babel-cli babel-preset-flow eslint flow-bin pre-commit
yarn run eslint -- --init
yarn run flow init
Cons
- No consistency in one app from another.
Server Side
- Run latest ES code
Client Side
- Transpile it to a version browsers can use
- Has to use transpiled server side version
Support
https://github.com/nodejs/Release
| version | Support |
|---|---|
| 8.10 | AWS Lamba Support |