问题标签 [node-modules]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1761 浏览

node.js - Nock 拦截 HTTP POST 请求并在 CoffeeScript 中测试 Mocha/Node.js 模块期间挂起

我想知道您是否经历过“nock”模块拦截http请求但没有任何日志记录就停止的情况……至少在我看来。我可能错了。这是测试:

...

如您所见,Nock 的日志记录已打开,但它没有记录任何内容。模块在 test - domain 中发出的 HTTP 请求被拦截,这意味着它没有到达实际的服务器。res.on('data' or 'end') 不会从模块中的请求中调用:

如果关闭 Nock 拦截,则该模块工作(到达服务器并由模块处理响应)。有了这个,我得出结论,问题是箭尾拦截。此外,如果 HTTP POST 请求是从测试文件本身发出的,而不是从模块发出的,它就可以工作……测试文件在 JS 中,但在 CoffeeScript 中的模块……这不重要吗?任何帮助表示赞赏

0 投票
0 回答
129 浏览

node-modules - 通过 require 导入的节点模块没有方法

我遇到了无法解决的节点模块问题。我有以下三个文件。我已经包含了感兴趣的基本方法,但排除了其余方法和方法的实际内容。

我正在努力解决的问题是,当从 events.js 节点对 event_queue 对象调用 publish_event 方法时,会崩溃并出现以下错误:

FATAL TypeError: Object # has no method 'publish_event', stack: TypeError: Object # has no method 'publish_event' at Events.publish_event (/Users/mburbidg/stormcloud/ccapi/cloud_pipes/node_modules/f5/server/services/event/ events.js:137:15)

我无法弄清楚这一点,您可以看到我可以在我们的系统中使用另一个模块 index.js 中的 EventQueue 对象的方法。我已经检查了几次其他明显的名字。

关于如何进行的任何建议?

文件 1 - f5/server/notifications/sqs_event_queue.js



文件 2 - f5/server/index.js



文件 3 - f5/server/services/event/events.js



0 投票
2 回答
6755 浏览

node.js - .gitignore and node_modules

I am trying to figure out the best way to handle node_modules in git. From what I read, there are two options:

A. Keep all the node_modules in the git repository, together with my project. This way, a person cloning my project does not have to install any modules.

B. Don't keep any node_modules in the git repository, i.e., have a ".gitignore" file that contains "node_modules".

However, in some projects, I don't see any of these two options. For example, in this node.js project, there are no node_modules, but also no .gitignore file...

When I fork this repo, and do npm install, the folder is filled with node_modules, and since there is no .gitignore, git tries to commit them...

What am I doing wrong?

0 投票
5 回答
25114 浏览

node.js - 如何使用具有不同/自定义模块名称的 npm 安装软件包

我想从一个名为“mymodule”的github tarball中安装一个特定的修订版,并将其命名为“mymoduleTemp”,然后加载一个可能不同的版本,该版本将采用真实名称“mymodule”。

那么,我该怎么做第一件事呢?我正在寻找类似的东西:

有没有办法做到这一点?一个不错的:

  • 如果 mymodule 已经存在,则在安装 mymoduleTemp 时它不会被破坏(即理想情况下,该过程不会安装为 mymodule 然后重命名文件夹)
0 投票
1 回答
320 浏览

node.js - 节点没有解析客户端模块

我有一个 Node 应用程序,我想在其中使用 socket.io 将数据传送到由冰沙显示的客户端。我在两个不同的节点环境中(通过 NPM)安装了两个包,并且在这两种情况下都在我的项目的 node_modules 子目录中。其中一个环境是 BeagleBone Black,另一个是 Cloud9 IDE 环境。在这两种情况下,socket.io 模块都可以解析并且工作正常,但是路径名的组合无法解析冰沙模块(如果我直接从 GitHub 中提取它,我可以开始工作)。

以下是 Cloud9 IDE 的服务器端代码的相关位:

以下是来自客户端的相关位:

正如我所说,这两个模块都位于上述脚本所在的项目目录的 node_modules 子目录中。节点文档描述了应该如何解析包含(http://nodejs.org/api/modules.html#modules_all_together),我认为我可以按照它如何解析到 socket.io 的链接的路径通过index.js 路线...但是当我在前面放一个“/”时它也可以工作,但我找不到路径。没有路径的排列或组合使冰沙模块解析。顺便说一句,smoothie 是一个小型图表应用程序,可以在 npm 中以该名称找到。

任何帮助,将不胜感激。

0 投票
19 回答
678981 浏览

github - 如何直接从 GitHub 安装 npm 包

尝试从 GitHub 安装模块会导致此错误:

package.json 上的 ENOENT 错误。

使用 express 轻松复制:

npm install https://github.com/visionmedia/express抛出错误。

npm install express 作品。

为什么我不能从 GitHub 安装?

这是控制台输出:

0 投票
1 回答
1166 浏览

node.js - Add and update data to Solr-4.3.0 using node module solr-client

Let me take an example to explain the scenario. Suppose i have data indexed to Solr as :

Now i want to modify the data already indexed to Solr with id : 872919092. I need to change the filename : science_book with filename : history_book and add new attribute topic : mughal to the same indexed data keeping path unchanged. I do not want to pass the path again as there is no change in that and already indexed to Solr. According to the documentation of Solr this is possible. How do i do that using nodejs solr-client update method? I want to achieve the below scene :

  1. If the attribute does not exist in the Solr indexed data with particular id, add that to the already indexed data keeping the previously indexed data unchanged.
  2. If the attribute already exists in the Solr indexed data with particular id, change the value of the previously indexed attribute keeping the other indexed data unchanged.

I am passing the data to add in Solr as a hash which is a combination of only the new attributes to be added to already indexed data in Solr and changes in the value of the previously indexed data to Solr.

Note : I am using Solr-4.3.0 and node module solr-client for adding data to Solr.

0 投票
3 回答
10194 浏览

node.js - 如何通过 Node.js 修改 MP3 元数据并保存?

我想实现以下目标:

  • 读取 MP3 元数据
  • 修改该元数据的编码(如果我可以修改该元数据的内容,那就更好了)
  • 保存对该 MP3 文件的修改

所有这些操作都可以基于本机 Node.js(无需浏览器)。是否有任何模块提供这样的功能或者我可以基于它开发?

0 投票
2 回答
138 浏览

node.js - node.js 模块自我与需要它的 js 对话

我在理解如何在 app.js 和模块之间“上下”交谈时遇到问题......

我认为它带有回调,但我也看到了 self._send()、this.send() 和 module.exports.emit 之类的东西

我很困惑。

我最近从 npm 安装了 pdfkit(相当不错的 6/10 :p)我想通过为 doc.write() 添加完成事件/回调来稍微改进它来学习。

我知道它不是那么重要,但我一直在查看我安装的模块,这可能是最简单的代码示例,不会伤害到“完成”我还认为这个函数在使用时会很好学习fs.writeFile 有一个 function(){},它在编写完成时触发,所以我可以看到它在代码中的结束位置,这使它成为一个简单的学习工具。

我已经修改了几次代码,试图比较模块以查看在哪里完成了类似的事情,但我只是不断地用错误打破它,我觉得我没有得到任何地方:

在 pdfkit 模块 document.js 中,我进行了更改:

在我的 app.js 中:

我也不确定我在谷歌上查询什么,请有人帮助我吗?

0 投票
2 回答
4580 浏览

node.js - 无法运行全局安装的节点模块

我是 node.js 的新手,仍在设置其环境的过程中。

我安装了 node.js v0.8.14 和 npm v1.1.65。我尝试将几个模块安装到我正在处理的项目中。他们工作得很好。

然后,我安装了一些全局模块,比如 node-dev 和 node-inspector。据我所知,没有错误。我得到的结果如下:

但是,当我尝试使用它时。它只是说:

我重新安装了它。没有改变。我/usr/local/share/npm/bin/根据类似问题的一些答案添加到 .bashrc 中。它仍然不起作用。

最后,我什至尝试导航到/usr/local/share/npm/bin/node-dev直接调用。同样的错误。不过,如果我在 Finder 中双击 node-dev 文件。它将显示一些结果:

我完全糊涂了。有人知道这里发生了什么吗?

顺便说一句,我使用的是 Mac OSX 10.8.4。

编辑:我发现如果我使用完整路径,这些全局安装的脚本将起作用。例如,/usr/local/share/npm/bin/node-dev有效,但node-dev无效。即使我尝试在下面执行它/usr/local/share/npm/bin