Tag: node modules

如何使用NodeJS在SSH2上执行多个命令

我试图部署从GitHub使用我想执行多个命令,按照数组的顺序。 我现在使用的代码包含在下面。 async.series([ … // Deploy from GitHub function (callback) { // Console shizzle: console.log(''); console.log('Deploying…'.red.bold); console.log(); console.log(); var deployFunctions = [ { command: 'cd ' + envOptions.folder + ' && pwd', log: false }, { command: 'pwd' }, { command: 'su ' + envOptions.user, log: false }, { command: 'git pull' }, { command: […]

npm从父目录安装

我有一个像这样的目录结构: /a/b/c 目录c包含package.json并且应该包含node_modules 。 我如何执行内部目录中a npm install ? 我试过这样的方式: npm –prefix b/c install b/c但是这样,所有符号链接直接在c中创build,而不是默认的node_modules/.bin 。 有什么办法可以实现吗? 节点:6.2.2 npm:3.10.2

无法parsing'babel-loader'

我正在尝试configuration我的第一个节点反应的应用程序。 我不断收到一个错误,说“无法parsingbabel-loader”。 用Googlesearch这个错误,我发现了一些不起作用的build议。 首先是将以下内容添加到我的webpack.config.js中 // resolveLoader: { // modulesDirectories: '/usr/local/lib/node_modules' // }, 尝试产生一个错误,说: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. – configuration.resolveLoader has an unknown property 'modulesDirectories'. These properties are valid: object { alias?, aliasFields?, cachePredicate?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, […]

茉莉花节点找不到spec模块

我有一个用coffeescript编写的准系统规范: # test/foobar.spec.coffee describe "falsy test", -> it "should fail", -> expect(true).toBe false 当我从项目目录运行jasmine-node –coffee test/foobar.spec.coffee ,出现以下错误: Exception loading: /Users/myuser/programming/project/test/foobar.spec.coffee { [Error: Cannot find module '/Users/myuser/programming/project/test/foobar.spec'] code: 'MODULE_NOT_FOUND' } 我在用: node –version v0.10.8 jasmine-node –version 1.13.0 有谁知道这是为什么发生?

如果我们不closuresmysql节点js模块中的mysql连接,是否有任何问题

如果我们不closures或结束节点js中的mysql连接,它是否影响function。 我正在这样做 var mysql = require('mysql'); var connection = mysql.createConnection(…); connection.query('SELECT 1', function(err, rows) { // connected! (unless `err` is set) }); 我的代码中没有结束mysql连接。 我的问题是需要closuresmysql连接。 如果我们不closuresmysql连接,将来我会遇到其他任何问题。 请帮我joinnodejs 编辑1我不会遇到任何问题,如无法连接,打开等太多的连接,意味着任何资源相关的问题? 对。 EDIT2 如果我们不手动结束它或使用end函数,在哪一瞬间mysql连接将会closures?

如何在每个“npm install <package>”运行后运行安装后脚本

我正在维护以下目录结构: /home/user/Desktop/ |– app/ | |– package.json | `– server.js |– node/ | |– bin/ | | |– node | | `– npm | |– include/ | |– lib/ | `– share/ | `– npm.sh 我希望我的所有本地安装的节点模块驻留在目录node 。 也就是说,如果我在目录app运行npm install ,最初它会将模块安装在当前目录( app )中,然后将node_modules文件夹移动到名为node的外部目录。 为此,我写了一个脚本npm.sh ,并将mv (move)命令放在package.json的postinstall脚本中。 这些是npm.sh和package.json文件。 内容npm.sh : #/bin/bash export PATH=/home/user/Desktop/node/bin:$PATH export NODE_PATH=/home/user/Desktop/node/node_modules export NODE_MODULE_ROOT=/home/user/Desktop/node […]

node.js:从另一个模块访问本地variables

我的问题 我正在编写一个名为a的node模块,它require() sa模块b (由陌生人编写)。 不幸的是, a不仅需要访问公共成员,还需要访问在模块范围内声明的局部variables。 // a var b = require('b'); console.log(b.public); console.log(b.private); // undefined // b var c = require('c'); var stdin = process.stdin; exports.public = true; var private = true; 我的解决scheme // a var b = require('b'); var srcPath = require.resolve('b'); console.log(b.public); fs.readFile(srcPath, 'utf-8', function (err, src) { var box = {}; […]

package.json中的“style”字段

我注意到Bootstrap和Normalize.css在package.json中都有一个“style”字段。 为什么他们有这个? 如果我不得不猜测,那就是允许用户像定义require('bootstrap')一样容易地导入已定义的样式表,但似乎并非如此。

events.js:160扔呃; //未处理“错误”事件

我所从事的这个项目是用吞噬build造的。 最近我更新了节点版本到v6.3.1。 然后出现了一些问题。 名为“html”的任务会引发错误。 这是它的错误代码的一部分。 bogon:toClient work$ gulp html (node:2519) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version. [10:26:10] Using gulpfile ~/Project/TIME_Cancer_Treatment_Centers_of_America(CTCA)/toClient/gulpfile.js [10:26:10] Starting 'html'… (node:2519) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs […]

nodejs模块名称中的“!”字符是做什么的?

我已经开始使用实习库来编写functiontesting,我意识到我不明白这个语法: var assert = require('intern/chai!assert'); var registerSuite = require('intern!object'); 这是什么目的! require()方法的参数中的字符?