require

installing typings require failed in macOSX

六眼飞鱼酱① 提交于 2019-12-11 13:24:28
问题 I following a tutorial to 'use PouchDB for localStorage in ionic' and the author says i need run this command: typings install require --ambient --save i know in version 1.0 of typings, ambient changed to global but when i run this command i get an error: sudo typings install require --global --save typings ERR! message Unable to find "require" ("npm") in the registry. Did you want to try searching another source? Also, if you want contribute these typings, please help us: https://github.com

when including() or require() do I always have to use ../../ relative to my file? Is there a simple way?

断了今生、忘了曾经 提交于 2019-12-11 12:48:12
问题 I'm building a web app that has php files spread out through different directories, so a typical file may have several includes. All these files everywhere. a php file may look like this: include('../../some.php'); require('../../some.php'); and in another file you may have something like this: include('../../../../some.php'); require('../../../../some.php'); point being, this can get a little bit out of hand, and somewhat difficult to keep track of. Is there a way I can do this so that I don

Node 中 CommonJS 规范

家住魔仙堡 提交于 2019-12-11 12:41:43
CommonJS 是一个很大的规范 Node 和浏览器只是借用了它的一部分精华 先来Node环境运行的结果: # a.js console.log('我是a.js') 无引用的情况: # b.js const lib = require('./a') console.log('我是b.js') # 运行b.js 我是a.js 我是b.js 有引用的情况: # b.js const lib = require('./a') console.log('我是b.js',lib) # 运行b.js 我是a.js 我是b.js {} //得到一个空对象 有 exports 情况,通过 exports 定义模块的输出: # a.js exports.hello='world!' // 这里可以挂载合法的数据类型,对象、字符串、函数等 console.log('我是a.js') # b.js const lib = require('./a') console.log('我是b.js',lib) # 运行b.js 我是a.js 我是b.js { hello: 'world!' } //得到一个含有 key 的对象 `key` 就是挂载到 `exports` 上的属性名 b.js require 的引用和 a.js exports 的引用是不是同一个引用? # a.js exports.hello

ECMAScript 6 入门——前言/简介

倾然丶 夕夏残阳落幕 提交于 2019-12-11 11:49:05
简介(看看就好,搭配括号理解就行) ECMAScript 6.0(以下简称 ES6)是 JavaScript 语言的下一代标准,已经在 2015 年 6 月正式发布了。它的目标,是使得JavaScript语言可以用来编写复杂的大型应用程序,成为企业级开发语言。 因此,ES6 既是一个历史名词,也是一个泛指,含义是 5.1 版以后的 JavaScript 的下一代标准,涵盖了ES2015、ES2016、ES2017等等,而ES2015则是正式名称,特指该年发布的正式版本的语言标准。本书中提到ES6的地方,一般是指ES2015标准,但有时也是泛指“下一代 JavaScript 语言”。 ECMAScript 和 JavaScript的关系是 前者是后者的规格,后者是前者的一种实现(另外的 ECMAScript 方言还有 JScript 和 ActionScript)。日常场合,这两个词是可以互换的。 各浏览器ES6支持程度 https://kangax.github.io/compat-table/es6/ Babel 转码器(如.jsx/.vue转码) Babel 是一个广泛使用的ES6转码器,可以将ES6代码转为ES5代码,从而在现有环境执行。这意味着,你可以用ES6的方式编写程序,又不用担心现有环境是否支持。下面是一个例子。 配置文件.babelrc Babel 的配置文件是

'Can't locate file.pl in @INC…' error in Perl

↘锁芯ラ 提交于 2019-12-11 10:52:55
问题 I have a folder with several .pl files that run through main.pl . I have successfully had these working by using require 'file.pl'; at the beginning of the main file. I have used some modules, too, without issue. I am now trying to use a 'home-made' module, but when I add use Add::Location::CSearch qw(c_search); to the top of the file that it is being used in (or the top of the main file) and run the main file, it produces the Can't locate file.pl in @INC... error with file.pl being the first

PHP中include()与require()的区别

萝らか妹 提交于 2019-12-11 10:35:58
require 的使用方法如 require("MyRequireFile.php"); 。这个函数通常放在 PHP 程序的最前面,PHP 程序在执行前,就会先读入 require 所指定引入的文件,使它变成 PHP 程序网页的一部份。常用的函数,亦可以这个方法将它引入网页中。 include 使用方法如 include("MyIncludeFile.php"); 。这个函数一般是放在流程控制的处理部分中。PHP 程序网页在读到 include 的文件时,才将它读进来。这种方式,可以把程序执行时的流程简单化。 他们两个的用途是完全一样的,不一定非得哪个放在最前面哪个放在中间。他们最根本的区别在于错误处理的方式不一样。 require一个文件存在错误的话,那么程序就会中断执行了,并显示致命错误 include一个文件存在错误的话,那么程序不会中端,而是继续执行,并显示一个警告错误。 以下为补充: 1. include有返回值,而require没有。 2. include()包括并运行指定文件 在处理失败时include() 产生一个警告,被导入的程序代码都会被执行,而且这些程序在执行的时候会拥有和源文件中呼叫到include()语句的位置相同的变量范围。你可以导入同一个服务器中的静态页面。 3. include_once()的作用和include()是几乎相同的

Is this a bug of require of Perl 5.8.8?

依然范特西╮ 提交于 2019-12-11 07:41:36
问题 Code as follows: #!/usr/bin/perl print 1; { require shift; } It turns out that when I run ./script script ,two 1 s are printed. So my script file is actually loaded twice? Is this a bug or not?? According to the document: "require" demands that a library file be included if it hasn’t already been included. 回答1: require only skips loading a file if it was previously loaded with require , use , or do , not for something loaded as the primary script. See: %INC 回答2: No, it's not a bug. Your

React Native Undefined is not an Object (evaluating 'this.state.input')

谁都会走 提交于 2019-12-11 05:49:38
问题 I am trying to build a word dictionary that translates English words to German words by following this tutorial. It utilize a json file which, I believe, contain keys with English words and its corresponding German words as values. The tutorial do that by using the require statement var english_german = require('./english_german.json'); but I would like to know if there is an alternative by using the import statement instead. The main problem I am facing, though, is that I am getting a

Jasmine 2.0 async beforeEach not waiting for async to finish

天大地大妈咪最大 提交于 2019-12-11 03:43:23
问题 I am using Jasmine 2.0 and require.js. I cannot get the async tests to work properly when I put the async code in a beforeEach function. My it statement is still running before the async call finishes. Here is my spec: describe("App Model :: ", function() { var AppModel; beforeEach(function(done) { require(['models/appModel'], function(AppModel) { AppModel = AppModel; done(); }); }); // THIS SPEC FAILS AND RUNS BEFORE ASYNC CALL it("should exist", function(done) { this.appModel = new AppModel

Node.js: How to get filename where function was required from within a module?

北城余情 提交于 2019-12-11 03:34:36
问题 I'm trying to get the original filename from where a module's function has been required from. I know you can use __filename to get the current file, but I want to get the original file. For example a simple module I have would be module.js module.exports(function() { return { print : function(message) { console.log(__filename + ' ' + message); }; } }); app.js var module = require('./module')(); module.print('hello'); What ends up happening is it will print module.js hello but I really want