随笔分类 -  node.js

1 2 下一页

这里有我的个人心得 和 学习笔记
npm 更换淘宝镜像源
摘要:1. 安装cnpm npm install -g cnpm --registry=https://registry.npm.taobao.org 2. 切换npm源 // 切换至淘宝源 npm config set registry https://registry.npm.taobao.org / 阅读全文

posted @ 2022-07-17 22:43 完美前端 阅读(885) 评论(0) 推荐(0)

node 自动复制粘贴并提交git
摘要:完整的代码, 可以复制引用 //导入必要的模块 const fs = require('fs') const exec = require('child_process').exec // 配置相关的路径 // 打包后的git本地仓库的路径 const cwd = '/Users/ff/Deskto 阅读全文

posted @ 2021-12-29 22:22 完美前端 阅读(206) 评论(0) 推荐(0)

node utils
摘要:// 引入依赖 const fs = require('fs'); // 删除指定路径下的所有文件 /** * 删除指定路径下的所有文件,但排除某些特定文件或文件夹。 * @param {string} path - 需要清空文件的路径。 */ function emptyDir(path) { c 阅读全文

posted @ 2021-12-29 22:22 完美前端 阅读(138) 评论(0) 推荐(0)

node.js http-server 搭建本地 http 和 https服务器
摘要:使用vue-cli创建的项目,能够实现浏览器中自动刷新,实时查看项目效果,其中的原理在于,webpack在本地启动了一个本地服务器,将本机当作一台服务器; 打包后的文件是一个html静态页面,在本地文件夹中直接打开的一般都素hifile协议,当代码中存在http或者https的链接时,html页面就 阅读全文

posted @ 2021-10-01 14:38 完美前端 阅读(612) 评论(0) 推荐(0)

node tools.js
摘要:let Tools = { contentType: { '.323': 'text/h323', '.3gp': 'video/3gpp', '.aab': 'application/x-authoware-bin', '.aam': 'application/x-authoware-map', 阅读全文

posted @ 2021-04-05 16:04 完美前端 阅读(78) 评论(0) 推荐(0)

node routes.js
摘要:#### Node.js路由处理代码 完整的代码, 可以复制引用 //导入依赖模块 let path = require('path'); let url = require('url'); let fs = require('fs'); let ejs = require('ejs'); let 阅读全文

posted @ 2021-04-05 16:03 完美前端 阅读(234) 评论(0) 推荐(0)

node 带mongodb
摘要:完整的代码, 可以复制引用, 全部写在一个文件里面 // 导入模块 let http = require('http'); // 引入HTTP模块 // 引入url模块 获取域名后面的url let path = require('path'); // 引入路径模块 let fs = require 阅读全文

posted @ 2021-04-05 16:02 完美前端 阅读(108) 评论(0) 推荐(0)

node 静态服务器
摘要:完整的代码, 可以复制引用 // 引入http模块 let http = require('http'); // 引入url模块 获取域名后面的url let path = require('path'); let fs = require('fs'); let url = require('url 阅读全文

posted @ 2021-04-04 14:36 完美前端 阅读(110) 评论(0) 推荐(0)

node自动重启 supervisor
摘要:安装 Supervisor Supervisor 安装命令 lpm -g install supervisor // 使用lpm命令安装supervisor,全局安装,只需要安装一次 使用 Supervisor 替换 Node 启动命令 // 使用supervisor替代node来启动app.js, 阅读全文

posted @ 2021-03-31 14:37 完美前端 阅读(60) 评论(0) 推荐(0)

node 获取url
摘要:完整的代码, 可以复制引用 let http = require("http"); // 引入http模块 let url = require("url"); // 引入url模块,用于格式化url // 创建HTTP服务器 http.createServer(function(request, r 阅读全文

posted @ 2021-03-31 14:32 完美前端 阅读(1206) 评论(0) 推荐(0)

node 启动命令
摘要:node app.js 打开 http://127.0.0.1:8888/index 阅读全文

posted @ 2020-09-22 12:16 完美前端 阅读(1898) 评论(0) 推荐(0)

node 修改json
摘要:app.js 文件内容 const fs = require('fs'); // 导入文件系统模块 let cn = require('./cn.json'); // 导入cn.json文件的数据 var temp = {}; // 遍历cn.json中的lhc_game_config数组,并为te 阅读全文

posted @ 2020-09-17 18:01 完美前端 阅读(582) 评论(0) 推荐(0)

nodejs querystring模块
摘要:这里主要记下querystring模块的使用方法。 querystring从字面上的意思就是查询字符串,一般是对http请求所带的数据进行解析。querystring模块只提供4个方法,在我看来,这4个方法是相对应的。 这4个方法分别是querystring.parse和querystring.st 阅读全文

posted @ 2020-05-03 13:10 完美前端 阅读(826) 评论(0) 推荐(0)

node.js 中使用 Mongodb
摘要:完整的代码, 可以复制引用 安装node的mongodb https://www.npmjs.com/package/mongodb const MongoClient = require('mongodb').MongoClient; const assert = require('assert' 阅读全文

posted @ 2020-05-03 11:18 完美前端 阅读(818) 评论(0) 推荐(0)

node.js web服务器 ejs插件使用 实现路由 get post请求
摘要:完整的代码, 可以复制引用 // 引入http模块 let http = require('http'); // 引入url模块 获取域名后面的url let path = require('path'); let fs = require('fs'); let url = require('url 阅读全文

posted @ 2020-05-01 10:16 完美前端 阅读(518) 评论(0) 推荐(0)

Content-type 所有类型的参数
摘要:{ '.323': 'text/h323', // H.323 网络电话 '.3gp': 'video/3gpp', // 3GPP 视频文件 '.aab': 'application/x-authoware-bin', // Authoware 二进制文件 '.aam': 'application 阅读全文

posted @ 2020-05-01 07:52 完美前端 阅读(3190) 评论(0) 推荐(0)

node.js 中的 fs 模块的使用
摘要:第三方包 // 使用 'mkdirp' npm包可以创建多级文件夹 Node.js内置的文件系统模块方法 let fs = require('fs'); // 1. 检测是文件还是目录 // fs.stat('./package.json', (err, data) => { // if (err) 阅读全文

posted @ 2020-04-30 17:17 完美前端 阅读(1370) 评论(0) 推荐(0)

common.js 自定义模块 和 npm install
摘要:工具类定义 // 定义一个tools工具类 let tools = { // get方法,用于获取数据 get: function () { console.log('get获取'); } } 模块导出 // 导出tools模块,供其他文件使用 module.exports = tools; NPM 阅读全文

posted @ 2020-04-30 15:41 完美前端 阅读(426) 评论(0) 推荐(0)

node.js 创建服务器
摘要:完整的代码, 可以复制引用 // 引入http模块 let http = require('http'); // 引入url模块 获取域名后面的url let url = require('url'); // 创建http服务 // request 获取客户端传过来的信息,response 给浏览器 阅读全文

posted @ 2020-04-30 09:35 完美前端 阅读(464) 评论(0) 推荐(0)

node.js 简介 安装 开发工具配置
摘要:Nodejs 介绍 Node.js 是一个 Javascript 运行环境(runtime)。它允许 JavaScript 开发后端程序,实现与其他后端语言相同的功能。Nodejs 基于 Google V8 引擎,这是 Google 发布的一个开源的 JavaScript 引擎,原本主要用于 Chr 阅读全文

posted @ 2020-04-30 08:03 完美前端 阅读(260) 评论(0) 推荐(0)

1 2 下一页

导航