Tag: 节点模块

节点错误:发送后无法设置标题。 怎么解决?

用户单击loginbutton后,服务器通过显示“发送后无法设置标题”错误来closures自身。 任何帮助? Server.js文件 app.put('/users/signin',function(req,res,next){ db.collection('users',function(err,usersCollection){ usersCollection.findOne({username:req.body.username},function(err,user){ bcrypt.compare(req.body.password,user.password,function(err,result){ if(result){ var token = jwt.encode(user,JWT_SECRET); return res.json({token:token}); }else{ res.status(400).send(); } }) }); }); res.send(); }); 控制器从哪里我打电话给服务器.. $scope.signin = function(){ $http.put('/users/signin',{username:$scope.username,password:$scope.password}) .then(function(res){ $cookies.put('token',res.data.token); $scope.currentUser = $scope.username; alert("Successfully signed in"); },function(err){ alert("bad login credentials"); }); };

Mocha-aure-reporter不使用节点js

当我用mocha-alure-reporter运行我的testing时,我遇到了问题,testing用mocha成功运行,但是mocha –reporter mocha-aure-reporter返回以下错误 > notifications-api@1.0.0 test /app > mocha –reporter mocha-allure-reporter 2016-11-15T06:13:26.762Z – info: Notification API up and running on port 4000 2016-11-15T06:13:26.773Z – error: Tue, 15 Nov 2016 06:13:26 GMT uncaughtException 2016-11-15T06:13:26.775Z – error: TypeError: test.currentRetry is not a function at Runner.<anonymous> (/app/node_modules/mocha-allure-reporter/index.js:29:19) at emitOne (events.js:77:13) at Runner.emit (events.js:169:7) at next (/app/node_modules/mocha/lib/runner.js:517:10) at Runner.runTests […]

无法抓取ally.com

我能够抓取像nature.com,flipkart.com.is这样的webistes。它工作得很好。 但当我尝试爬行ally.com,nike.com。 它返回状态码403,并说未定义。 这是我的代码 // crawlerqueue.js var request = require('request'); var cheerio = require('cheerio'); var URL = require('url-parse'); var pa11y=require('pa11y'); var START_URL = "http://www.nature.com/"; //var SEARCH_WORD = "stemming"; var MAX_PAGES_TO_VISIT = 100; var pagesVisited = {}; var numPagesVisited = 0; var pagesToVisit = []; var url = new URL(START_URL); var baseUrl = url.protocol + "//" […]

CSS找不到Dyson模块节点

我在Node js上使用Dyson模块,但我的应用程序没有findcss文件夹。 我有这个: /demoDyson dyson-demo.js /node_modules /public /css style.css /services /GET _index.js test.js dyson-demo.js : var express = require('express'), dyson = require('dyson'), path = require('path'); dyson.bootstrap({ configDir: __dirname + '/services', port: 8765 }); var myApp = express(); myApp.use(express.static(path.join(__dirname, 'public'))); _index.js : module.exports = { path: '/', render: function(req, res) { var html = '<h1>dyson</h1><p>Example endpoints:</p>'; […]

如何压扁发布的NPM模块的文件结构

我有一个TypeScript项目,我作为一个NPM模块发布。 编译项目的输出在{mymodule}/dist/src/… ,这意味着当我发布时,NPM模块也采用上述文件结构。 这样做的缺点是需要单个模块时,它看起来像这样: var individualModule = require('/dist/src'); 我想扁平化已发布模块的输出,其中已发布模块中的文件将是{mymodule}/…而不是{mymodule}/dist/src/…

从子文件夹中需要一个node_module

所以我有一些node.js文件 /folder/app.js /folder/node_modules/moduleIwanttoload /folder/subfolder/file.js 如何从moduleIwanttoload需要moduleIwanttoload ?

如何“子类化”一个node.js模块

我多年来一直是Perl编程人员,但也有C ++的背景,所以我来自“经典”面向对象的背景,现在正在学习node.js。 我刚刚阅读了“面向对象的JavaScript原则” ,它很好地向像我这样有经典头脑的人解释面向对象的JS概念。 但我留下了一个问题,具体涉及到node.js和inheritance。 如果我还在用“古典”词汇来解释我的问题,请原谅我。 让我们假设我有一个模块lib/foo.js : function foo() { console.log('Foo was called'); } module.exports.foo = foo; 我想在另一个模块lib/bar.js ”这个: var foo = require('foo.js'); // Do some magic here with *.prototype, maybe? function bar() { console.log('Bar was called'); } module.exports.bar = bar; 这样我的主要脚本可以做到这一点: var bar = require('lib/bar.js'); bar.foo(); // Output "Foo was called" bar.bar(); // […]

如何正确地将node_modules移动到不同的位置

我试图将我的node_modules移动到不同的位置,我所做的是删除node_modules,并将package.json移动到我希望它被安装的位置,然后运行npm install ,其中安装了node_modules,但是现在,如果我运行npm start ,服务器启动,我得到了很多错误: (index):5 GET http://localhost:3000/node_modules/bootstrap/dist/css/bootstrap.min.css (index):9 GET http://localhost:3000/node_modules/es6-shim/es6-shim.min.js (index):10 GET http://localhost:3000/node_modules/systemjs/dist/system-polyfills.js (index):12 GET http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js (index):13 GET http://localhost:3000/node_modules/systemjs/dist/system.src.js (index):14 GET http://localhost:3000/node_modules/rxjs/bundles/Rx.js (index):15 GET http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js (index):16 GET http://localhost:3000/node_modules/angular2/bundles/http.dev.js (index):21 Uncaught ReferenceError: System is not defined(anonymous function) @ (index):21 我更新了index.html文件,以使用根目录node_modules中的文件而不是当前目录的node_modules。 还有什么我应该做的,以使其工作? 请注意,index.html与node_modules位于不同的目录中

phantomjs在访问aws-sdk时找不到节点模块“encryption”

我有一个应用程序正在使用幻影js和nodejs应用程序。 我正在使用节点应用程序中的几个节点模块,这是通过幻像js运行。 我需要使用亚马逊节点aws-sdk。 我安装了它 npm install aws-sdk 该节点的应用程序能够find一旦我这样做 var AWS = require('aws-sdk'); 但它开始提示其他本地节点js模块的错误,其中三个具体是“encryption”,“定时器”,“path”。 我检查了/ usr / lib / nodejs文件夹和那些在那里,所以如何phantomjs节点应用程序无法find它们? 具体的错误 Error: Cannot find module 'crypto' phantomjs://platform/bootstrap.js:299 in require phantomjs://platform/bootstrap.js:263 in require phantomjs://platform/util.js:4 TypeError: undefined is not a function (evaluating 'AWS.util.update') phantomjs://platform/core.js:16 Error: Cannot find module 'path' phantomjs://platform/bootstrap.js:299 in require phantomjs://platform/bootstrap.js:263 in require phantomjs://platform/api_loader.js:3 Error: Cannot […]

我如何在laravel中使用节点模块?

在我的资源/资产/ js我有tests.js,我使用gulp来build立所有js包括这个文件,在这个文件中我有 var cmd = require('node-cmd'); cmd.get( 'echo 3', function(data){ console.log('You are returning: ',data) } );` 我想要使​​用这个模块,但不是在根目录中的公共目录或在根以外的其他目录,有任何可能使用需要function例如从公用文件夹使用gulp?