草庐IT

npm-private-modules

全部标签

javascript - 使用 Npm 模块时的 jQuery 插件

我是Npm包(来自Ruby)的新手,正在尝试加载一个不一定在NPM上的jQuery插件。我正在构建一个Chrome扩展。下面的代码用于注入(inject)到浏览器中的content.js脚本。因此,格式化和日期选择器等组件是可取的。在我的应用程序文件的顶部,我有以下内容:varReact=require("react");var$=require("jquery");varmoment=require("moment");一切正常,但现在我想添加一个插件,但我不太确定将它放在哪里以及如何让应用程序访问它。我试过像这样加载它:varReact=require("react");var$=

javascript - 运行 Gulp 会抛出错误 "Cannot find module ' ./lib/_stream_writable.js'”

我正在构建一个关于Root'sSageWordPressTheme的主题.设置并运行必要的命令后。每当我运行Gulp时,它都会抛出以下错误module.js:338throwerr;^Error:Cannotfindmodule'./lib/_stream_writable.js'atFunction.Module._resolveFilename(module.js:336:15)atFunction.Module._load(module.js:278:25)atModule.require(module.js:365:17)atrequire(module.js:384:17)a

javascript - Node module.exports 返回未定义

我遇到了Node.js和module.exports的问题。我知道module.exports是一个返回对象的调用,该对象具有分配给它的任何属性。如果我有这样的文件结构://formatting.jsfunctionFormat(text){this.text=text;}module.exports=Format;用这个://index.jsvarformatting=require('./formatting');有没有办法初始化一个Format对象并像这样使用它?formatting('foo');console.log(formatting.text);每当我尝试这样做时,我都

javascript - typescript + moment.js : error TS2307: Cannot find module 'moment'

我正在开发一个网络应用程序,使用angular1.5、typescript2.4.0、moment:2.18.1和gulp进行项目组装。这是我的tsconfig.json:{"files":["src/app/main.ts","types/**/*.ts"],"compilerOptions":{"noImplicitAny":false,"target":"es2015","allowSyntheticDefaultImports":true}}在我的date-range-picker.component.ts中。我正在导入时刻库,正如maindocumentation中所建议的那

javascript - 为什么 npm react-scripts 在我运行 `npm run start` 时会产生语法错误?

这个问题在这里已经有了答案:SyntaxError:missing)afterargumentlist,Whenusingasync(3个答案)关闭3年前。所以我已经在全栈React应用程序上工作了几个月。出于某种原因,当我尝试在命令行上运行npmrunstart时,似乎不知何故,它产生了以下错误;//npmrunstart>pair@0.1.0start/Users/eden/Documents/GitHub/Pair./pair>react-scriptsstart/Users/eden/Documents/GitHub/Pair./pair/node_modules/react-

javascript - 为什么谷歌的闭包库不使用真正的私有(private)成员?

我成为JavaScript开发人员已有一段时间了,我一直认为在JavaScript中实现私有(private)成员的正确方法是使用DougCrockford在此处概述的技术:http://javascript.crockford.com/private.html.在我开始使用GoogleClosure库之前,我不认为这是一个特别有争议的JavaScript智慧。想象一下我的惊讶......图书馆没有努力使用Crockford风格的信息隐藏。他们所做的只是使用特殊的命名约定并在文档中注明“私有(private)”成员。我习惯于假设Google的人通常处于软件质量的领先地位,那又如何呢?遵

javascript - 错误 : Cannot find module 'wrench' , 当我运行 gulp 命令时出现此错误

我已经在本地和全局安装了npm、bower和gulp。当我在该文件夹中运行gulp时,仍然出现此错误。Error:Cannotfindmodule'wrench'atFunction.Module._resolveFilename(module.js:325:15)atFunction.Module._load(module.js:276:25)atModule.require(module.js:353:17)atrequire(internal/module.js:12:17)atObject.(/home/myPC/documents/workspace/frontend/gul

javascript - 访问原型(prototype)中的 "private"变量

是否可以在JavaScript中创建一个可以在原型(prototype)中访问的私有(private)变量?我尝试了以下obviouslydoesn'twork,因为bar只能从Foo中访问,而不能从原型(prototype)中访问。functionFoo(){varbar='test';}Foo.prototype.baz=function(){console.log(bar);};我知道我也不能使用this.bar='test',因为那样会使thepropertypublic据我所知。如何使bar变量私有(private),但可由原型(prototype)访问?

javascript - 如何知道 npm `unzip` 模块何时完成解压缩文件?

我正在使用npm的unzip模块来提取zip存档的内容。我需要知道它何时完成提取以及文件已完全写入磁盘。我的代码:fs.createReadStream('master.zip').pipe(unzip.Extract({path:'gitdownloads/repo'}));我尝试过的:我的第一个想法是我可以接入流并监听完成事件,但是unzip只接受输入:它不会返回另一个流。我还查看了unzip模块是否有“完成”回调。运气不好。 最佳答案 来自githubREADMEExtractemitsthe'close'eventoncet

javascript - POST 方法在 npm http-server 上抛出错误 405

我正在尝试发出Ajax请求以在本地http服务器上运行php文件。我得到一个Error405:methodnotallowed在我的浏览器控制台中。我已经尝试了一些类似问题的答案,但无济于事。我正在使用npmhttp-server来托管它。我已经尝试在http服务器上启用CORS,但这并没有解决问题。我可以将我的问题缩小到以下代码(使用给定的答案here)。/test.html:ButtonClickMe$(document).ready(function(){$("button").click(function(){$.ajax({method:'POST',url:'echo.ph