# Linux Kernel Module Cheat

#### 27.7.2. Node.js

rootfs_overlay/lkmc/nodejs

Host installation shown at: https://askubuntu.com/questions/594656/how-to-install-the-latest-versions-of-nodejs-and-npm/971612#971612

Build and install the interpreter in Buildroot with:

    ./build-buildroot --config 'BR2_PACKAGE_NODEJS=y'

Everything is then the same as the Python interpreter setup, except that the executable name is now `node`!

TODO: build broken as of LKMC 3c3deb14dc8d6511680595dc42cb627d5781746d + 1:

    ERROR: package host-nodejs installs executables without proper RPATH

Examples:

- rootfs_overlay/lkmc/nodejs/hello.js: hello world

- String

  - rootfs_overlay/lkmc/nodejs/alphanumeric.js: https://stackoverflow.com/questions/4444477/how-to-tell-if-a-string-contains-a-certain-character-in-javascript/58359106#58359106

- `process`

  - rootfs_overlay/lkmc/nodejs/command_line_arguments.js

- `fs`

  - rootfs_overlay/lkmc/nodejs/file_write_read.js

  - rootfs_overlay/lkmc/nodejs/read_stdin_to_string.js Question: https://stackoverflow.com/questions/30441025/read-all-text-from-stdin-to-a-string

- `class`

  - rootfs_overlay/lkmc/nodejs/object_to_string.js: `util.inspect.custom` and `toString` override experiment: https://stackoverflow.com/questions/24902061/is-there-an-repr-equivalent-for-javascript/26698403#26698403

  - rootfs_overlay/lkmc/nodejs/object_to_json.js: `toJSON` examples

  - rootfs_overlay/lkmc/nodejs/static.js

- rootfs_overlay/lkmc/nodejs/http.js: `http` module to create a simple HTTP server: https://nodejs.org/api/http.html

- rootfs_overlay/lkmc/nodejs/esm: https://stackoverflow.com/questions/58384179/syntaxerror-cannot-use-import-statement-outside-a-module

- Node.js step debugging

- NPM