node.js

Failed to lookup view “error” in views directory

青春壹個敷衍的年華 提交于 2021-02-11 13:23:59
问题 Failed to lookup view "error" in views directory Here is my code: app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'ejs'); console.log("set views") // uncomment after placing your favicon in /public //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); app.use(logger('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); app.use(cookieParser()); app.use(express.static(path.join(__dirname, 'public'))); 回答1: You can solve it

How to run unit tests with Cypress.io?

北慕城南 提交于 2021-02-11 13:23:42
问题 I have been using Cypress.io to run end-to-end tests. Recently, I have been using it to run unit tests as well. However, I have some issues with some small helper functions that I have built with NodeJs. I have a create file called utils.spec.js in the following path <my-project-name>/cypress/integration/unit/utils.spec.js & I have written the following tests: File: utils.spec.js // Path to utils.js which holds the regular helper javascript functions import { getTicketBySummary } from '../..

sending http request from azure web app to my machine

旧时模样 提交于 2021-02-11 13:22:14
问题 I created an azure web app which send an http request: axios.post('http://*mypublicip*:3000/write/' + Name, { content: data[1] }) meanwhile my computer has a running express server: app.listen(3000, () => console.log(`Server running on port ${port}`)); all my functionality works when I use it locally by sending the request to localhost instead of my ip. I also tried adding host '0.0.0.0' to my app.listen. what am I missing? thanks 回答1: This problem has nothing to do with your webapp . So I

sending http request from azure web app to my machine

可紊 提交于 2021-02-11 13:21:56
问题 I created an azure web app which send an http request: axios.post('http://*mypublicip*:3000/write/' + Name, { content: data[1] }) meanwhile my computer has a running express server: app.listen(3000, () => console.log(`Server running on port ${port}`)); all my functionality works when I use it locally by sending the request to localhost instead of my ip. I also tried adding host '0.0.0.0' to my app.listen. what am I missing? thanks 回答1: This problem has nothing to do with your webapp . So I

Azure Linux App Service with .Net Core Stack. Unable to use NodeJS

和自甴很熟 提交于 2021-02-11 13:21:29
问题 I am hosting a .NET Core Application on MS Azure (on a Linux Service Plan) and I want to run some NodeJS code in the .NET Core Application. I did this a while ago on a Windows Service Plan, there it was working. Now I am trying with a Linux Plan and it is not working. First I was trying to use "Jering.Javascript.NodeJS" and then also "INodeServices" from Microsoft (which is obsolete). But "node" was not found. I also tried to start directly a Process (Code below), but also not working. "node"

[NODEMON]- babel-node not recognized as internal or external command

孤人 提交于 2021-02-11 13:18:23
问题 I am trying to setup a simple express server. I am using nodemon to start my development server But my app keeps crashing because it does not recognize the "babel-node" command. The error output is [nodemon] 2.0.7 [nodemon] to restart at any time, enter `rs` [nodemon] watching path(s): *.* [nodemon] watching extensions: js,json [nodemon] starting `babel-node index.js` 'babel-node' is not recognized as an internal or external command, operable program or batch file. [nodemon] app crashed -

Unable to upload images with React dropzone

三世轮回 提交于 2021-02-11 13:18:12
问题 I am using react-dropzone to get files on my react application and i am trying to upload these multiple images using axios. Backend is in mongo+express. But, for some reasons, image is not being received at the backend. MY react code is: const data = new FormData(); data.append("title", entry.title); entry.images.forEach((image, index) => { console.log(image) /*This prints out File ​​ lastModified: 1599303132607 ​​ name: "name.jpg" ​​ path: "name.jpg" ​​ size: 41142 ​​ type: "image/jpeg" ​​

How to catch “access error” when publish inaccessible topic in mqtt.js?

可紊 提交于 2021-02-11 13:13:51
问题 I am creating a project using node.js with mqtt.js and mosquitto broker. In mosquitto config file, I have setup a pwfile, aclfile to control which topic can be accessed by which user. Everything works fine, if the username, password, publish topic and subscribe topic are correct. But if I change the publish topic to an inaccessible topic, it seems successfully publish the topic without any error in mqtt.js, but the message is never been publish. Is there anyway to catch error when publish or

Trouble with generating PDF file to upload to firebase

房东的猫 提交于 2021-02-11 13:11:15
问题 I'm learning about puppeteer and firebase at the moment. What I am trying to do is create a pdf of a web page and upload to firebase storage. This is my code. const puppeteer = require('puppeteer'); const fs = require('fs').promises; const firebase = require('firebase'); require("firebase/storage"); const url = process.argv[2]; if (!url) { throw "Please provide URL as a first argument"; } var firebaseConfig = { #Firebase Config Goes here }; // Initialize Firebase firebase.initializeApp

Logstash beats input “invalid version of beats protocol”

冷暖自知 提交于 2021-02-11 13:10:20
问题 I'm writing a kibana plugin and a logstash pipeline. For my tests, I just wrote a logstash input like that: input { beats { port => 9600 ssl => false ssl_verify_mode => "none" } } But when I try to open a connection with node (code above): invoke = (parameters, id, port, host) => { var fs = require('fs'); console.log(`Sending message in beats, host= ${host}, port= ${port}, message= ${parameters.message}`); var connectionOptions = { host: host, port: port }; var client = lumberjack.client