node.js

Electron crashes when requiring sqlite3 native module in forked process

感情迁移 提交于 2021-02-10 03:58:39
问题 I'm trying to use sqlite3 module in a child process with electron, but I get error of undefined symbol. Also, the error happens only when I run the program from electron's node.js, but when I run the program from usual node.js everything works fine. I think the problem may be related to 'nativeness' of sqlite3 module, and I tried electron-rebuild , npm --build-from-source , they didn't help. main.js: const { fork } = require('child_process'); fork('fork'); fork.js: const sqlite3 = require(

MongoDB toArray performance

半世苍凉 提交于 2021-02-10 03:24:25
问题 I'm trying to build a category tree from a term collection in Mongo/Node, but first I select all tree elements using $in: console.time('termsCol.find'); var terms = await termsCol.find({term_id: {'$in': flatTree}}); console.timeEnd('termsCol.find'); console.time('termsCol.toArray'); terms = await terms.toArray(); console.timeEnd('termsCol.toArray'); This performs: termsCol.find: 0.162ms termsCol.toArray: 30.910ms I've read posts about toArray performance on SO, but would like to know if

Logging multiline messages in heroku

邮差的信 提交于 2021-02-09 20:43:48
问题 I'm developing an application using NodeJS and deployed in Heroku. I need to log multi-line messages (eg. stacktraces and other multiline information) but would like to retain them as one log message each. The problem is that when using console.log (or any framework that uses console.log / stdout ) with a multiline message it's interpreted like multiple messages by Heroku (one message per each line in the original message). I think the problem lies in that Heroku reads the messages from the

Logging multiline messages in heroku

☆樱花仙子☆ 提交于 2021-02-09 20:41:57
问题 I'm developing an application using NodeJS and deployed in Heroku. I need to log multi-line messages (eg. stacktraces and other multiline information) but would like to retain them as one log message each. The problem is that when using console.log (or any framework that uses console.log / stdout ) with a multiline message it's interpreted like multiple messages by Heroku (one message per each line in the original message). I think the problem lies in that Heroku reads the messages from the

node.js的express框架

这一生的挚爱 提交于 2021-02-09 15:31:29
1.我选择了eclipse。 当然可能更多的人喜欢用webstorm,这都不是关键 首先在eclipse中安装一下node插件, 然后选择eclipse marketplace,搜索node,会有很多Node插件可供选择, 我选择的是 。 2. new一个node.js express project。 项目结构: node_modules: Web项目的模块管理,即你有任何的模块都有应该封装后放在此处,如连接数据库模块。 public: 该文件夹下还有三个文件夹images,javascripts,stylesheets,含义很明显了,就不说了吧。 routes: 路由规则,即Web的控制器,即mvc中的controller。 views: 视图,但是这种视图并不是传统的html文件,而是html的引擎模板,这里默认的模板是jade文件,可以认为是前台UI,当然你在新建node.js express project的时候可以选择jade或者是ejs。 app.js: myFirstWeb的入口,packege.json里有定义 "start": "node app.js",这里很有必要把app.js代码解读一遍: /** * Module dependencies. */ var express = require('express') , routes = require('.

「前端工程化」该怎么理解?

自作多情 提交于 2021-02-09 13:40:10
关注「 前端向后 」微信公众号,你将收获一系列「用 心 原创」的高质量技术文章,主题包括但不限于前端、Node.js以及服务端技术 一.什么是前端工程? 一个类似的术语是软件工程(Software Engineering): Software engineering is the systematic application of engineering approaches to the development of software. 将工程方法系统化地应用到软件开发中,就叫软件工程 。那么,紧接着又有两个问题: 工程方法是什么? 系统化怎么理解? 工程是指使用科学原理设计和制造机器、结构等,比如修桥、铺路、建隧道、造车、盖房子: Engineering is the use of scientific principles to design and build machines, structures, and other items, including bridges, tunnels, roads, vehicles, and buildings. 具体到软件领域,指的是 以系统、严谨、可量化的方法开发、运营、维护软件 ,软件工程包括对这些方法的应用和研究: Software engineering the application of a systematic,

Node-gyp and custom dependency / library / header install path

元气小坏坏 提交于 2021-02-09 12:25:27
问题 I have a build environment in which my libraries (and headers) are installed to a custom location. When installing a package from npm, modules that use node-gyp fail because they cannot find the libraries (or headers) I've installed. How can I make node-gyp aware of my custom install location (linux)? 回答1: If you set CXXFLAGS and LDFLAGS before npm install <pkg> in the same line, it seems to work: $ CXXFLAGS=-I/path/to/include LDFLAGS=-L/path/to/lib npm install <pkg> Alternatively you can

How to add NODE_PATH to webpack in package.json?

社会主义新天地 提交于 2021-02-09 11:54:11
问题 How do I add NODE_PATH to webpack in package.json? Part of my packcage.json: "dependencies": { "axios": "^0.16.2", "cross-env": "^5.0.1", "koa": "^2.3.0", "koa-mount": "^3.0.0", "koa-static": "^4.0.1", "koa-trie-router": "^2.1.5", "mongodb": "^2.2.31", "nuxt": "^1.0.0-rc3", "socket.io": "^2.0.3" }, "devDependencies": { "babel-eslint": "^7.2.3", "backpack-core": "^0.4.1" }, "scripts": { "test": "mocha --harmony", "dev": "NODE_PATH=./app backpack dev", "build": "nuxt build && backpack build",

npm run start working whereas ng serve not working

假如想象 提交于 2021-02-09 11:49:05
问题 I try to run angular 2 app with ng serve in Linux machine. It is not working. But I tried npm run start command. It is working fine. I got the following message when I tried ng serve command. As a forewarning, we are moving the CLI npm package to "@angular/cli" with the next release, which will only support Node 6.9 and greater. This package will be officially deprecated shortly after. To disable this warning use "ng set --global warnings.packageDeprecation=false". You have to be inside an

Install type definitions automatically when I install an npm package

一笑奈何 提交于 2021-02-09 11:47:45
问题 Is there a way to configure npm in such a way so that whenever I install a package, it will: Check if it has type definitions inside it If it does not, try to install @types/PACKAGE with the --save-dev flag Ideally, I'd like this to happen automatically (as a plugin or something) without writing a shell script that will limit the API. For example, I might write a shell script such as: (note that this doesn't really answer all the requirements) #!/bin/bash npm install --save $1 && npm install