Node.js Development Environment and Application Examples

Node.js: concise and refreshing
How to enable auto-completion for default/builtin functions in IDEA
IDEA node.js function autocomplete
Batch Editing of Files Containing “Netsuite” in Their Names, Adding Tags and Categories
Successful solution for the monthly requirement: seeking a batch categorization solution. The code below can be easily expanded and applied to modify content within disk directories.
The Node.js source code is as follows:
1 | var fs = require("fs"); |
Sublime Text Editor: Opening a Directory
When opening a directory in the Sublime Text editor, it automatically loads all files within the folder (a convenient way to update articles). Then, utilize the “Find” menu and select “Replace” to search for specific strings. The search content also supports regular expressions.
Node.js Development Steps
Git clone
- Clone using an IDE editor (e.g., WebStorm)
Open the IDE, the Terminal Tab will automatically switch to the current nodejs directory from the clone
- npm install
- If encountering version issues (e.g., local runtime environment version too low), download and install a newer version, or directly place the node executable file in the /usr/local/bin directory (for Mac environment, I placed four file versions: node, npm, npx, corepack, and it upgraded)
- npm run dev
- If issues arise, specific packages might need installation, for example: npx patch-package
- [Optional] npx vite build
- npm install
Directly edit Node.js code
In a network environment, it may be necessary to bypass firewalls before npm commands:
1
HTTPS_PROXY="http://127.0.0.1:7890"
Debugging
1
2
3
4
5On MacOS or Linux, run the app with this command:
DEBUG=myapp:* npm start
On Windows Command Prompt, use this command:
set DEBUG=myapp:* & npm start
Node.js Build Steps
Compile to the current project’s dist directory: npm run build
Detailed steps can be found in the article Node.js Project Packaging and Deployment Implementation
Docker Compilation
docker build -t ipserver .
Node.js Docker Container
Currently, I’m not familiar with building an entire Docker package, so I will first create a Node.js Docker container for better management.
1 | version: "3" |
This section is based on ideas from the article Installing Node.js Docker Container on Mac
Node.js Docker Deployment Steps
- docker exec -it nodejs bash
- [Optional steps, applicable only for upgrade deployment]
- ps -falx | head -1; ps -falx | grep ‘npm|node’
- kill -9 「node process id, PPID value」
- node /home/app/blogsearch/bin/www
Question: How can we ensure that this node persistently runs in the background, meaning that when exiting the current docker exec -it nodejs bash by pressing control+c, the process does not terminate?
Upcoming Release
Tested: Adding full text Search via FlexSearch to a Blog
To begin: https://expressjs.com/en/starter/installing.html
1 | mkdir blogsearch |
This idea is based on Adding full text Search via FlexSearch to a Blog