NAIO & Node.js All In One
Node.js Tutorials
https://nodejs.org/en/docs/
https://nodejs.org/en/docs/guides/
-
https://nodejs.org/en/docs/guides/#general
https://nodejs.org/en/docs/guides/getting-started-guide/ -
https://nodejs.org/en/docs/guides/#node-js-core-concepts
https://nodejs.org/en/docs/guides/blocking-vs-non-blocking/ -
https://nodejs.org/en/docs/guides/#module-related-guides
https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/
node.js tutorials
https://www.w3schools.com/nodejs/
https://www.javatpoint.com/nodejs-tutorial
https://www.tutorialspoint.com/nodejs/
https://stackify.com/learn-nodejs-tutorials/
https://www.codecademy.com/learn/learn-node-js
node.js 教程
https://www.runoob.com/nodejs/nodejs-tutorial.html
https://www.liaoxuefeng.com/wiki/1022910821149312/1023025235359040
https://www.cnblogs.com/chyingp/p/nodejs-learning-guide-github-got-1000-stars.html
https://github.com/chyingp/nodejs-learning-guide
https://nqdeng.github.io/7-days-nodejs/
https://nodejs.jakeyu.top/
https://www.zhihu.com/question/19793473
videos
https://www.imooc.com/course/list?c=nodejs
https://edu.aliyun.com/course/469/lesson/list
node.js & write file & read file
write & read
https://stackoverflow.com/a/15554600/5934465
https://stackoverflow.com/a/2497040/5934465
// preview.js
const fs = require("fs");
const readline = require("readline");
fs.writeFile("file.js", `export const APP_ENV = "preview";`, function(err) {
if(err) {
console.log(err);
return err;
}
let env = "preview";
console.log("The file was saved!", env);
});
let rd = readline.createInterface({
input: fs.createReadStream("file.js"),
output: process.stdout,
console: false
});
rd.on("line", function(line) {
console.log(`line =`, line);
});
// fs.writeFile("file.txt", "prview", function(err) {
// if(err) {
// console.log(err);
// return err;
// }
// console.log("The file was saved!");
// });
// global.APP_ENV = "testing";
// let APP_ENV = global.APP_ENV;
// console.log(`APP_ENV =`, APP_ENV);
// let rd = readline.createInterface({
// input: fs.createReadStream('file.txt'),
// output: process.stdout,
// console: false
// });
// rd.on('line', function(line) {
// console.log(`line =`, line);
// });
// testing.js
const fs = require("fs");
const readline = require("readline");
fs.writeFile("file.js", `export const APP_ENV = "testing";`, function(err) {
if(err) {
console.log(err);
return err;
}
let env = "testing";
console.log("The file was saved!", env);
});
// const rl = readline.createInterface({
// input: process.stdin,
// output: process.stdout
// });
// absolute path
// fs.open("/open/some/file.txt", "r", (err, fd) => {
// if (err) {
// throw err;
// }
// fs.close(fd, (err) => {
// if (err) {
// throw err;
// }
// });
// });
// global.APP_ENV = "testing";
// let APP_ENV = global.APP_ENV;
// console.log(`APP_ENV =`, APP_ENV);
// relative path
// fs.open("file.js", "r", (err, fd) => {
// if (err) {
// throw err;
// }
// console.log(`fd =`, fd);// 3
// fs.close(fd, (err) => {
// if (err) {
// throw err;
// }
// });
// });
let rd = readline.createInterface({
input: fs.createReadStream("file.js"),
output: process.stdout,
console: false
});
rd.on("line", function(line) {
console.log(`line =`, line);
});
// file.js
export const APP_ENV = "testing";
bash shell
mkdir -p
# mkdir -p /xyz/abc 父级文件夹不存在也可创建
$ mkdir -p /xyz/abc
cli & env runtime
https://www.jikexueyuan.com/course/1332_2.html
cmd
#!/usr/bin/env node
echo "^v^ app is running in production building!" && npm run build
bash
#!/usr/bin/env bash
echo "^v^ app is running in production building!" && npm run build
process.argv
tj & commander.js
https://github.com/tj?tab=repositories
https://github.com/tj/commander.js
https://github.com/xgqfrms/vscode/issues/20
https://github.com/tj/commander.js/blob/master/Readme_zh-CN.md
minimist
https://github.com/substack/minimist
--val
-v
& --version
options & help
usage.txt
color
v 1.0.0
colors
https://github.com/xgqfrms-GitHub/Node-CLI-Tools
CLI & CLP
npm link
nvm
强烈建议使用nvm(Node Version Manager) ,nvm是 Nodejs 版本管理器,它让我们方便的对切换Nodejs 版本。