require

Node.js global require

孤人 提交于 2020-01-13 09:01:13
问题 how can i require a module globally so i can use it in different modules without having to require it again? or do i just have to do that everytime? is there any best practice for this? heres an example of what i am talking about. lets say i have an index.js like this: var a = require('a.js'), utils = require('utils.js'); var str = 'hello this is a test'; str = a.change(str); utils.return(str); a.js var utils = require('utils.js'); exports.change = function(str) { str = str.replace('test',

Ubuntu+OpenSSL安装+not found (required by openssl)

允我心安 提交于 2020-01-13 07:46:28
转载源地址: https://www.jianshu.com/p/25126152ad27 下载 地址:https://www.openssl.org/source/openssl-1.1.1a.tar.gz 下载后解压, tar -zxvf openssl-1.1.1a.tar.gz 进入解压目录下软件的根目录: cd ~/openssl-1.1.1a/ sudo ./config sudo make && sudo make install 编译安装完成后,查看版本: openssl version 若报错提示: openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory 或 > openssl version > openssl: /usr/lib/x86_64-linux-gnu/libssl.so.1.1: version `OPENSSL_1_1_1' not found (required by openssl) > openssl: /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1: version `OPENSSL_1_1_1' not found

Does Node run all the code inside required modules?

蹲街弑〆低调 提交于 2020-01-13 07:46:13
问题 Are node modules run when they are required? For example: You have a file foo.js that contains some code and some exports. When I import the file by running the following code var foo = require(./foo.js); is all the code inside the file foo.js run and only exported after that? 回答1: Much like in a browser's <script> , as soon as you require a module the code is parsed and executed. However , depending on how the module's code is structured, there may be no function calls. For example: // my

tp5 整合 个推

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-13 04:17:53
这里因为业务需要使用推送功能 uni 里面前端集成了个推 所以选择了个推来做推送. 个推的官方文档地址: http://docs.getui.com/getui/server/php/start/ 在个推官方没有找到 composer 包 只能手动的将 sdk 放到了项目中 sdk下载地址: http://www.getui.com/download/docs/getui/server/GETUI_PHP_SDK_4.1.0.0.zip (官方文档里有建议从官方文档下载) 这里的用的是tp5框架 laravel yii 和 ci 中需要用到的朋友 可以根据各自的框架调整下 自行加载到这个类调整下配置读取即可 下载解压 把它放到 项目根路径\extend 文件夹内即可 这里 个推的demo 都是 以函数的方式 呈现的 这里我自己将他整理成了一个类 GeTui.php <?php namespace getui; class GeTui { private $host = 'http://sdk.open.api.igexin.com/apiex.htm'; //测试 private $appkey = ''; private $appid = ''; private $mastersecret = ''; private function init() { // header(

react native底部tab栏切换

£可爱£侵袭症+ 提交于 2020-01-12 17:54:58
1.安装tab栏插件 npm i react-native-tab-navigator --save 2.引入对应的组件和tab插件 import { Platform, StyleSheet, Text, View,Image } from 'react-native'; import TabNavigator from 'react-native-tab-navigator'; 3.复制以下代码到render()函数的return 里 两个图标的地址: https://raw.githubusercontent.com/knightsj/GitHubPopular-SJ/master/github_client/res/images/ic_polular.pnghttps://raw.githubusercontent.com/knightsj/GitHubPopular-SJ/master/github_client/res/images/ic_trending.png <View style={styles.container}> <TabNavigator> <TabNavigator.Item selected={this.state.selectedTab === 'home'} title="最热" renderIcon={() => <Image style=

初涉Node的模块和包

 ̄綄美尐妖づ 提交于 2020-01-12 16:58:48
摘抄自《NodeJS开发指南》 模块是Node.js应用程序的基本组成部分,文件盒模块是一一对应的。换言之,一个Node.js文件就是一个模块。这个文件可能是JavaScript代码、JSON或者编译过的C/C++扩展。 【创建模块】 Node.js提供了exports和require两个对象,其中exports是模块公开的接口,require用于外部获取一个模块的接口,即所获取模块的exports对象。 特点: 单次加载 。即无论调用多少次require,获得的模块都是同一个。 exports本身仅仅是一个普通的空对象,即{},它专门用来声明接口,本质上是通过它为模块闭包的内部建立了一个有限的访问接口。 【 创建包 】 包是在模块基础上更深一层的抽象。 Node.js的包是一个目录,其中包含一个JSON格式的包说明文件 pachage.json 。 来源: https://www.cnblogs.com/desperadom/p/3653039.html

gulp常用插件之gulp-rev-delete-origina使用

て烟熏妆下的殇ゞ 提交于 2020-01-12 11:05:34
更多gulp常用插件使用请访问: gulp常用插件汇总 gulp-rev-delete-origina 这是一款删除由 gulp-rev 或 gulp-rev-all 重写的原始文件 。 更多使用文档请点击访问gulp-rev-delete-origina工具官网 。 安装 一键安装不多解释 npm install --save-dev gulp-rev-delete-origina 使用 var gulp = require('gulp'); var rev = require('gulp-rev'); var revcss = require('gulp-rev-css-url'); var revdel = require('gulp-rev-delete-original'); gulp.task('rev', function () { return gulp.src('./app/**/*') .pipe(rev()) .pipe(revcss()) .pipe(revdel()) .pipe(gulp.dest('./build/')) ; }); 参数: exclude 过滤器, RegExp 或 function 允许您排除某些文件,使其不被删除。 例: RegExp: revdel({ exclude: /build\.css$/ }); Function:

electron, after browserify, fs.existsSync is not a function

痞子三分冷 提交于 2020-01-12 06:23:52
问题 i read a lot about browserify and electron and the gui browser issue yet there is still a problem with browserify, saying "fs.existsSync is not a function", and "required is not defined" * The full story* i created simple gui with electron , there are the package.json file, the main.js and the index.html file + 3,4 html files, where there i want to create simple "load show save window" that work with require That feature worked in the index.html file yet doesn't work properly in the load.html

electron, after browserify, fs.existsSync is not a function

空扰寡人 提交于 2020-01-12 06:22:27
问题 i read a lot about browserify and electron and the gui browser issue yet there is still a problem with browserify, saying "fs.existsSync is not a function", and "required is not defined" * The full story* i created simple gui with electron , there are the package.json file, the main.js and the index.html file + 3,4 html files, where there i want to create simple "load show save window" that work with require That feature worked in the index.html file yet doesn't work properly in the load.html

node读书笔记

大城市里の小女人 提交于 2020-01-11 04:58:12
node读书笔记 Node.js不是JS应用、而是JS运行平台 Node.js 采用C++语言编写而成, 是一个 Javascript 的运行环境。 Node.js 采用了 Google Chrome 浏览器的 V8 引擎, 性能很好, 同时还提供了很多系统级的 API, 如文件操作、网络编程等。浏览器端的 Javascript 代码在运行时会受到各种安全性的限制,对客 户系统的操作有限。相比之下,Node.js 则是一个全面的后台运行时,为 Javascript 提供了其他 语言能够实现的许多功能。 Node.js采用事件驱动、异步编程,为网络服务而设计 Node.js 的网络模块特别多, 包括 HTTP、 DNS、 NET、UDP、HTTPS、TLS 等,开发人员可以在此基础上快速构建 Web 服务器。以简单的 helloworld.js 为例: var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(80, "127.0.0.1"); Node.js的特点 事件驱动 非阻塞I/O 单线程 Node.js应用案例 善于I/O