节点可执行文件无法在node-debugger pkg的primefaces中find

当我按F5开始debugging时,发生下面的错误 无法启动debugging器。 退出代码是ENOENT,表示找不到节点可执行文件。 尝试使用node-debugger.nodePathconfiguration设置在primefacesconfiguration文件中指定显式path。 我试图添加一些像下面的configuration,但它不工作。 我不确定我是否正确添加了它。 vim〜/ .atom / config.cson "node-debugger": nodePath: "/usr/bin/node" 你可以帮帮我吗? 先谢谢你。

发送邮件后,Nodemailer速度很慢

在用户提交联系表单之后,我使用nodemailer发送邮件,然后用户将被定向到一个感谢页面。 我现在在cloud9上开发了这个项目。 这是我的代码: var express = require("express"), bodyParse = require("body-parser"), multer = require("multer"), nodemailer = require("nodemailer"); var app = express(); app.use(bodyParse.urlencoded({extended: true})); var smtpTransport = nodemailer.createTransport({ service: "Gmail", auth: { type: "OAuth2", user: "xxxxx@gmail.com", clientId: "xxxxxx", clientSecret: "xxxxx", refreshToken: "xxxxx", accessToken: "xxxxx" } }); app.post("/upload", function(req, res){ var mailOptions = { from: "xxxx <xxxx@gmail.com", // […]

mongoose关注/追随者

我正在尝试为nodejs / mongoose驱动的网站添加以下/ followersfunction。 我正在使用下面的方法正确存储ID的问题。 不太清楚发生了什么问题,但似乎只是将ID保存到下面的部分,而不是更新第一部分的追随者。 我知道,如果用户ID只是传递到发布请求会很容易,但我认为将用户ID存储在前端是一种安全问题,所以只是使用用户名来获得ID会更好。 // Handles the post request for following a user router.post('/follow-user', function(req, res, next) { // First, find the user from the user page being viewed User.findOne({ username: req.body.username }, function(err, user) { // Add to users followers with ID of the logged in user user.followers = req.user._id; // […]

Node.js:fs.readdir不会返回由fs.writeFile写入的文件

我的应用程序 一个简单的Node.js http服务器,它通过调用POST /deploy在给定的目录中创build文件。 在写入文件后,我想使用console.log列出该目录中的所有文件。 为了创build文件( POST /deploy ),我打电话给: fs.writeFile(filename, content, 'utf8', callback(null, {'newFile': filename})); callback函数写入HTTP响应,并使用以下命令列出文件: fs.readdir(some_directory, (err, files) => { files.forEach(file => { console.log(file); // Do something with the file } } 我的问题 新文件没有在callback中列出。 只有在我再次调用部署之后,才会列出上一个文件。 例如,如果我使用/deploy连续创build文件a和b ,则仅在创buildb时列出b ,并且在进行另一次调用之前b不会列出。 我假设在调用callback函数时文件没有closures,只有在稍后调用fs.readdirclosures后fs.readdir看到文件。 我怎样才能调用callback函数只有在文件被正确closures,并可以使用fs.readdir列出? 我试过了什么 阅读fs.close()手册。 它工作,但需要一个fd ,而不是文件名,所以我必须打开文件只是为了closures它,这似乎很麻烦: fs.open(fd,write,buffer){fs.cln(fd,callback(null,{'newFile':filename })); }); }); 在SO中寻找类似的问题

passport-saml lib不能正确解密带有私钥解密密钥的saml EncryptedAssertion

我有一个encryption的SAML 2.0响应/断言,我需要解密。 格式如下所示: <saml:EncryptedAssertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"> <xenc:EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"> <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/> <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <xenc:EncryptedKey> <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"/> <xenc:CipherData> <xenc:CipherValue>{some ciphers}</xenc:CipherValue> </xenc:CipherData> </xenc:EncryptedKey> </ds:KeyInfo> <xenc:CipherData> <xenc:CipherValue>{assertion body}</xenc:CipherValue> </xenc:CipherData> </xenc:EncryptedData> </saml:EncryptedAssertion> 我也有这样的格式的私人解密密钥: —–BEGIN RSA PRIVATE KEY—– {mumbo jumbos} —–END RSA PRIVATE KEY—– 我已经尝试在这里使用OneLogin的saml解密工具来解密encryption的SAML断言(复制并粘贴到该input框),它就像一个魅力。 https://www.samltool.com/decrypt.php 但是,当我试图使用nodejs,passport-saml导入私钥文件并尝试解密响应时,如果我省略(“—– BEGIN —-”),则会得到“Invalid PEM formated”或“— END —”标题),或者得到“无效的RSAES-OAEP填充”错误。 这是我的代码片段: const fs = require('fs'); const Promise = […]

通过nodejs执行python脚本

我试图执行这段执行python脚本的节点js代码。 通过这个代码工作正常。 但是立即在前端显示“运行”和“结束”的响应。 一旦python脚本的执行完成,就必须显示“finshed”。 app.post('/execute', function(request, response){ response.write("running"); console.log("executing") var pyshell = new PythonShell('./python_codes/test.py') pyshell.on('message', function (message) {console.log(message);}); pyshell.end(function (err) {if (err){throw err;};console.log('finished');}); response.write("finished"); response.end(); });

内存不足,试图创build大的csv文件

使用Meteor并在服务器上尝试通过在Meteor集合中循环并插入一行来生成一个大型的csv文件。 在某些时候,服务器将会出现内存不足的错误 – 我的猜测是在循环结束之前内存不足,具体取决于集合的大小。 我怎样才能解决这个问题(以某种方式清除内存)? 代码如下: var job = Jobs.findOne(); var fs = Npm.require('fs'); var file = '/tmp/csv-' + job._id + '.csv'; var headers = ["Email", "Processed?", "Integration", "Passed?", "Reason", "Date"]; var stream = fs.createWriteStream(file); var first_line = headers.join() + '\n'; var wstream = fs.createWriteStream(file); var emails = rawEmails.find(); wstream.write(first_line); emails.forEach(function(rawemail) { var line_item = […]

如何添加与VueJs img src属性

在我的NodeJs路由中,我有以下几点: router.get('/list/:id', function(req, res, next) { request("http://localhost:3000/api/journal/" + req.params.id, function(error, response, body) { var json = JSON.parse(body); res.render('listdetail', { title: 'Journal', data: json }); }); }); 数据是一个包含我所有屏幕字段的json对象。 其中一个领域是一个图像的base64演示文稿。 然后,在我的清单详细html我有以下几点: <div id="app"> <img class="materialboxed" src="{{data.base64Image}}" width="200"> </div> 这肯定是行不通的…我如何添加到src属性由NodeJS发送的base64信息? 我也尝试了以下内容: <img class="materialboxed" :src=imagebase64Source width="200"> <script type="text/javascript"> var app = new Vue({ el: '#app', data: { imagebase64Source: {{data.base64Image}} […]

我想创build一个下载button,但文件不下载?

我正在创build请求服务器下载文件的点击监听器的下载button 代码点击侦听器: downloadFileClick(event){ $.ajax('/download', {data:{}}).done(function(data){ }.bind(this)); } 在服务器端下面的代码正在运行 app.get('/download', function(req, res){ var file = __dirname + '/write/imageout.png'; res.download(file); }); 文件不在浏览器中下载。 我检查了从服务器发送给客户端的响应,它发送文件内容,但不从浏览器下载。

Postgres,Docker和Node.js – 密码身份validation失败(连接被拒绝或psql:FATAL:angular色“root”不存在)

我只是不知道为什么我不能使用Node.jslogin到Postgres user: postgres password: postgres host: 192.168.99.100 port: 5432 database: test_db 以下是导致错误的Node.js中的几行代码 error: password authentication failed for user "postgres" var pg = require('pg'); var conString = "postgres://postgres:postgres@192.168.99.100:5432/test_db"; var client = new pg.Client(conString); client.connect(); 我从Docker容器运行Postgres。 我启动了另一个容器,并可以使用以下命令成功访问数据库 psql -U postgres -d test_db -h 192.168.99.100 -W 此外我可以使用pgAdmin 4成功login 的pg_hba.conf # TYPE DATABASE USER ADDRESS METHOD # "local" is […]