node.js

Deployment error. Build failed: Build error details not available. Firebase Cloud Functions

丶灬走出姿态 提交于 2021-02-19 02:15:07
问题 I reinstalled multiple times NPM and Node on my pc. (npm version 7.4.3) (node version v15.7.0) I followed the procedure for configuring the Firebase CLI with: npm install -g firebase-tools and firebase init and firebase deploy and the configuration seems to work fine. The problem I'm facing happens when I open the index.js file and I uncomment the stock helloWorld function which looks like this: exports.helloWorld = functions.https.onRequest((request, response) => { functions.logger.info(

Node.js: require() and MODULE_NOT_FOUND

烈酒焚心 提交于 2021-02-19 01:48:34
问题 As a learning exercise, I am attempting to build a router in Node.js, which is meant to be reusable. The file structure for my router looks like this: /myProject app.js /routes index.js about.js /modules /router router.js In app.js , I create a router object, and pass it the path to my routes folder: var Router = require('./modules/router/router'); var router = new Router('./routes'); Within the constructor of the router object, I load filenames into an array from the path passed to the

Node.js: require() and MODULE_NOT_FOUND

半城伤御伤魂 提交于 2021-02-19 01:48:30
问题 As a learning exercise, I am attempting to build a router in Node.js, which is meant to be reusable. The file structure for my router looks like this: /myProject app.js /routes index.js about.js /modules /router router.js In app.js , I create a router object, and pass it the path to my routes folder: var Router = require('./modules/router/router'); var router = new Router('./routes'); Within the constructor of the router object, I load filenames into an array from the path passed to the

Node and NPM Running script and Ctrl-C triggers SIGINT twice

与世无争的帅哥 提交于 2021-02-19 01:45:30
问题 I've come across a problem on one of my Nodejs apps running with npm start (which just does node app.js ). My app contains a sigint handler as follows: process.on('SIGINT', () => { db.disconnect().then({ process.exit(0); }).catch(e => process.exit(1)); }); With corresponding logs. After some testing on other files, I've noticed that Ctrl-C when on an npm process triggers SIGINT twice if the first one takes too long to exit. (try adding a timeout on a sample app). For now I've added a counter

In express.js req.protocol is not picking up “https” for my secure link. It always pics “http”

老子叫甜甜 提交于 2021-02-19 01:38:05
问题 req.protocol is not picking up "https" for my secure link. It always pics "http" . For creating my baseURL am using this. any solutions please? 回答1: That's happening most probably because there is a proxy in between. In my case I am using Heroku. If that's the case, you need to add app.enable('trust proxy'); to your express app. Without enabling that, req.protocol returned http . After that change I got https . You can also use req.secure to get true or false depending on if your app is

How can I redirect all clients to another page with socket.io?

人走茶凉 提交于 2021-02-19 01:35:30
问题 I am working on an online multiplayer cards against humanity game (React on the front, React router for redirecting, and Node in the back) I am trying to redirect all clients in a "lobby", or room, when one user in the lobby clicks "start", but right now only the user that clicks start is redirected. The idea is somebody will set up a new game, which will have a unique pin, where after you create the game and select your avatar, others can use that pin the join the lobby (this part is working

How to change or upgrade the version of Node.js in Meteor

我只是一个虾纸丫 提交于 2021-02-19 01:32:18
问题 I am using Meteor in one of my project and as i checked node version used by meteor via going /.meteor/local/build/.node_version.txt . Its using v0.10.43 of node.js . I am using a module that can only be run on node.js version v4.0.0 or greater than that. So i am just wondoring to know that is there any way we can change the version of the node.js in Meteor application if yes than how we can change that. I have installed node v5.8.0 locally in my ubuntu machine Thanks 回答1: Meteor 1.4 now

Mongoosejs refresh a document

丶灬走出姿态 提交于 2021-02-19 01:21:17
问题 Suppose I have a document for example: var doc = Model.findOne({name:"name"}); Now if the document gets edited trough another connection the the database, doc doesn't hold the right information. I do need it, so I have to "refresh" or "redownload" it from the database. Is there any way to do this with only the object "doc"? 回答1: Assuming doc contains the document instance to refresh, you can do this to generically refresh it: doc.model(doc.constructor.modelName).findOne({_id: doc._id},

Mongoosejs refresh a document

十年热恋 提交于 2021-02-19 01:20:51
问题 Suppose I have a document for example: var doc = Model.findOne({name:"name"}); Now if the document gets edited trough another connection the the database, doc doesn't hold the right information. I do need it, so I have to "refresh" or "redownload" it from the database. Is there any way to do this with only the object "doc"? 回答1: Assuming doc contains the document instance to refresh, you can do this to generically refresh it: doc.model(doc.constructor.modelName).findOne({_id: doc._id},

Foreign keys with Sequelize are not created

五迷三道 提交于 2021-02-19 01:16:09
问题 I use Sequelize for my Server (with mysql dialect); in Sequelize's documentation is written that this: var Task = this.sequelize.define('Task', { title: Sequelize.STRING }) , User = this.sequelize.define('User', { username: Sequelize.STRING }) User.hasMany(Task) Task.belongsTo(User) creates automatically foreign key references with constraints; but for me this doesn't happen: var Shop = sequelize.define('Shop', { name: Sequelize.STRING, address: Sequelize.STRING, phone: Sequelize.STRING,