npm

nodejs连接数据库

自闭症网瘾萝莉.ら 提交于 2021-01-30 11:56:35
1、下载模块 使用npm下载mysql模块 npm install mysql --save //--save代表自动把模块和版本号添加到devdependencies部分 2、引入mysql模块 //声明一个变量用来接收引入模块 var mysql = require ( 'mysql' ) 3、创建一个数据库连接 //声明一个变量接收 var connection = mysql . createConnection ( { host : 'localhost' , //主机域名,默认是localhost port : '3306' , //端口号,(可以省略) user : 'root' , //用户名 password : 'root' , //密码 database : 'sys' //数据库名称 } ) 4、进行连接(也可以省略) //connection是创建数据库连接的变量 connection . connect ( ) 5、执行增删改查SQL语句 首先复习一下SQL语句的增删改查 insert into 表名 values ( 字段 1 , 字段二 , 。。。。 ) ; delete from 表名 where 条件 ; ( 一定要加条件否则很危险 ) update 表名 set 字段一 = new_字段内容 , 字段二 = new_字段内容 , . . .

EasyNVR网页Chrome无插件播放摄像机视频功能二次开发之云台控制接口示例代码

孤街浪徒 提交于 2021-01-30 09:46:31
随着多媒体技术和网络通信技术的迅速发展,视频监控技术在电力系统、电信行业、工业监控、工地、城市交通、水利系统、社区安防等领域得到越来越广泛的应用。摄像头直播视频监控通过网络直接连接,可达到的世界任何角落,并能够通过控制云台、存储视频监控音视频,对现场远程运维,实现随时随地想看就看的安防需求。 背景需求 摄像机云台控制在摄像机当中很常见,摄像机能将当前状态下云台的水平角度、倾斜角度和摄像机镜头焦距等位置参数存储到设备中,需要时可以迅速调用这些参数并将云台和摄像头调整至该位置。 摄像机只要支持Onvif协议进行和第三方软件或设备对接,大部分都能进行远程控制。EasyNVR支持Onvif协议的设备云台控制,能实现和设备的实时数据传输及控制。 今天主要介绍通过EasyNVR接口二次开发,将云台控制及实时直播功能集成在自己的原有的web业务系统上。 demo效果如下: demo是通过vue-cli脚手架搭建起来,简单说一下,目录结构 对easy-player不了解的这是播放器插件地址可以参看( https://www.npmjs.com/package/easy-player ) 这里主要讲解一下App.vue内容文件 <template> <div id="app"> <!-- 测试鉴权 如果鉴权已关闭请忽略 --> <div class="div-btn"> <el-button

angular开发环境搭建及新建项目

拥有回忆 提交于 2021-01-30 08:11:13
  最近一个星期准备学习一下angular前端框架,因为之前在学习abp框架的时候,都要求前端要掌握angular,所以不得不回来恶补一下了,学习的过程有时间的话会记录在这里,方便以后复习。 闲言少叙,下面来介绍开发环境搭建的步骤: 开发环境搭建 1.安装node和npm(其实只需要安装node,因为npm会跟随node一起安装) 首先百度node.js ,进入node.js的官网: 如图所示,安装LTS版本的,LTS表示当前最稳定使用最广泛的版本的,Current表示最新版本的,推荐安装最稳定的版本。下载下来之后,直接点击安装,安装步骤很简单,直接下一步到底就可以了。 安装完成后,可通过控制台cmd(win + r cmd),输入如下命令查看node.js和npm的版本,命令如下: // node 版本 node - v // npm版本 npm -v 如果安装成功,则会显示如下信息: 2.安装cnpm npm和cnpm都是自动从网络上获取一些开发资源的工具,但是npm访问的是国外的资源,cnpm是访问的淘宝维护的国内的资源,所以在获取一些资源的时候,使用cnpm要快的多,下面给出使用npm安装cnpm的命令行: npm install -g cnpm --registry=https: // registry.npm.taobao.org 安装好后,结果如下: 3

Module not found: Error: Can't resolve 'fs' when using readFileSync

馋奶兔 提交于 2021-01-29 20:33:53
问题 I am trying to read a file from typescript and I'm using 'fs' module. import { readFileSync } from 'fs' import fs from 'fs' const fetchSavedCards = (): string[] => { fs.readFileSync('saved-card-details.txt','utf8'); ... }; Following error is given when building the project. ERROR in ./service/Service.ts Module not found: Error: Can't resolve 'fs' in '/project_path/front-end/src/service' @ ./service/Service.ts 1:0-34 29:15-27 @ ./component/body/cart/Cart.tsx @ ./component/body/Body.tsx @ ./App

Yarn workspaces: nohoist exclude

烈酒焚心 提交于 2021-01-29 20:29:11
问题 In my package.json, I currently have "workspaces": { "nohoist": ** } I would like to specify JUST TWO packages to hoist, and nohoist on everything else. Is there a simple way to do this without pasting all of my packages except those two into nohoist ? 回答1: After days of digging I ended up with the following configuration. Yarn seems to use some kind of Bash glob pattern matching (see this Linux journal article for a tutorial). In this configuration the "nohoist" rule disables hoisting for

Error: EACCES: permission denied, unlink '/usr/local/bin/npx'

只谈情不闲聊 提交于 2021-01-29 19:57:05
问题 I tried to install npm install -g npm to update and I don't know if it was necessary but it failed. How do I give it permission to unlink? 回答1: try using sudo prefix and try run it again 来源: https://stackoverflow.com/questions/57814364/error-eacces-permission-denied-unlink-usr-local-bin-npx

vue.v3@0.1.0 serve: `vue-cli-service serve`

荒凉一梦 提交于 2021-01-29 19:09:28
问题 i install bootstarp-vue " npm install bootstarp-vue " , i get a error When i run the project . λ npm run serve > vue.v3@0.1.0 serve G:\vue\vue.v3 > vue-cli-service serve 'vue-cli-service' is not recognized as an internal or external command, operable program or batch file. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! vue.v3@0.1.0 serve: `vue-cli-service serve` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the vue.v3@0.1.0 serve script. npm ERR! This is probably not a problem with

In WSL2: Ubuntu 20.04 for Windows 10 nodejs is installed but npm is not working

a 夏天 提交于 2021-01-29 18:18:52
问题 I am using WSL2: Ubuntu 20.04 in my Windows 10 operating system. I have installed nodejs using the command sudo apt-get install -y nodejs when I do node -v command I get v12.18.3 mrd@DESKTOP-2EO5K4H:/mnt/c/Users/musfi$ node -v v12.18.3 but when I do npm -v command I get this below command mrd@DESKTOP-2EO5K4H:/mnt/c/Users/musfi$ npm -v -bash: /mnt/c/Program Files/nodejs/npm: /bin/sh^M: bad interpreter: No such file or directory I also do whereis command. Hope this will help to find solution.

Angular build watch for multiple libraries and and serve to another app

吃可爱长大的小学妹 提交于 2021-01-29 17:21:59
问题 I developing three helper angular libraries that consumed by another main application. The ideal is having live rebuild for the libaries while my main app import those libraies and run at the same time so I can have live reload for my main app during development process of the libraries. I found ng build --watch and I use it mutiple times with run-s for each of my libary then npm link the built folder then npm link my-libary in my main app. But the problem is when a libary is rebuilt, It

Unexpected token: name (DocumentAttributes) with webpack and UglifyJs

荒凉一梦 提交于 2021-01-29 15:49:25
问题 I am using docx 5.0.2 version for generating word document with images from the angular type script code. using webpack.optimize.UglifyJsPlugin. Getting this error when building the code . Unexpected token: name (DocumentAttributes) with webpack and UglifyJs. I assume Uglify is not able to minimize or beautify code related to docx library. Any suggestions from people using the docx package. Build used to work fine before docx package added to the package.json 回答1: The problem here is with