package.json
{
"scripts": {
"serve": "node http-server.js",
},
"devDependencies": {
"chalk": "^4.1.2",
"connect": "^3.7.0",
"http": "^0.0.1-security",
"st": "^2.0.0"
}
}
http-server.js
var connect = require("connect");
var...
分类为 NodeJS 的文章:
{
type: 'module', // module / commonjs
}
type 字段的产生用于定义 package.json 文件和该文件所在目录根目录中 .js 文件和无拓展名文件的处理方式。值为 moduel 则当作 ES6 模块处理;值为 commonjs 则被当作 commonJs 模块处理,无 type 则为认为是 CommonJS
.mjs 后缀名的文件总是被当作 ES6 模块,.cjs 后缀名的文件总是被当成 CommonJS 模块
const packageInfo = require('./package.json');
const fs = require('fs');
const gitHEAD = fs.readFileSync('.git/HEAD', 'utf-8').trim();
const ref = gitHEAD.split(': ')[1];
let version = packageInfo.version;
let commitId = '';
if (ref) {
commitId = fs.readFileSync('.git/' + ref, 'utf-8').trim();
} else ...
yarn config set -g registry https://registry.npm.taobao.org
yarn config set -g disturl https://npm.taobao.org/dist
yarn config set -g electron_mirror https://npm.taobao.org/mirrors/electron/
yarn config set -g sass_binary_site https://npm.taobao.org/mirrors/node-sass/
yarn config set -g phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs/
yarn config set -g chromedriver_cdnurl http...
目录
安装NodeJS
安装WebSocket-Node
安装NodeJS
参考这里:
curl -sL https://rpm.nodesource.com/setup | bash -
yum install -y nodejs
安装WebSocket-Node
参考这里:
npm install websocket
工具
forever是nodejs的守护进程,能够启动,停止,重启我们的app应用
forever start app.js
forever start -o console.log -e console.error app.js
forever restartall
forever stopall
forever list
遇到的问...
package.json
{
"scripts": {
"serve": "node dev-server.js"
},
"devDependencies": {
"chalk": "^4.1.2",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"http-proxy-middleware": "^2.0.6",
"morgan": "^1.10.0",
"st&qu...