Tag: 系统

节点JS – 监听系统事件

根据下面的API文档,节点JS监听进程退出事件。 https://nodejs.org/api/process.html#process_event_exit 节点JS如何监听系统事件? 如插入USB,插入系统的CAMERA设备或Linux发出的任何自定义事件。

来自节点的堆栈跟踪有时会被截断。 我怎样才能看到完整的错误?

我有一个(故意)崩溃我的节点应用程序的路线。 当我访问这条路线时,我得到了一个崩溃的适当日志: /Users/me/Documents/myapp/routes/index.js:795 global.fakeMethod(); ^ TypeError: global.fakeMethod is not a function at null._onTimeout (/Users/me/Documents/myapp/routes/index.js:795:11) at Timer.listOnTimeout (timers.js:92:15) 但是,当我在systemd下运行相同的代码时,错误被截断。 它 May 17 10:03:56 a.myapp.com www[28766]: /var/www/myapp/routes/index.js:795 May 17 10:03:56 a.myapp.com systemd[1]: myapp.service: main process exited, code=exited, status=1/FAILURE May 17 10:03:56 a.myapp.com systemd[1]: Unit myapp.service entered failed state. May 17 10:03:56 a.myapp.com systemd[1]: myapp.service failed. May 17 […]

在打字稿中parsingXML

使用Typescript 2.0(tsc版本2.0.3)。 我没有成功尝试在angular2 / typescript应用程序中使用xml2js节点库(请参阅https://www.npmjs.com/package/xml2js )。 似乎很清楚,我不熟悉SystemJS设置库使用的方式。 要安装xml2js库,我做了以下操作: npm install –save xml2js npm install –save @types/xml2js 这里是相关的文件: tsconfig.json: { "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false, "outDir" : "build" } } systemjs.config.js /** * System configuration for Angular samples * Adjust as necessary for […]

使用sudo与ExecStart(systemd)

我试图让端口80上的node.js网站(我正在使用数字海洋)。 我在服务文件中使用systemd来做这个 … ExecStart=/usr/bin/nodejs /var/www/bin/app.js … 在本地主机上,如果我使用sudo来启动站点,但在没有sudo的情况下,这可以在端口80上正常工作。 显然你需要以1024以下的端口为根运行。 如何在ExecStart中允许sudo? 或者我在这里完全错误的方式,如果是这样,我怎么得到80端口的快递应用程序? 干杯,迈克

使用npm angular2导入库

我无法使用npm来设置这个库 。 完成的命令: npm install ng2-charts –save npm install chart.js –save 的index.html 我添加了这一行 <script src="node_modules/chart.js/src/chart.js"></script> app.module import { ChartsModule } from 'ng2-charts/ng2-charts'; @NgModule({ imports: [ BrowserModule, RouterModule.forRoot(router), HttpModule, ChartsModule, ], systemjs.config.js (function (global) { System.config({ paths: { // paths serve as alias 'npm:': 'node_modules/' }, // map tells the System loader where to look for […]

如何在Node.js中读取文件?

在Node.js中,我想读一个文件,然后用\n分隔文件的每一行console.log() 。 我怎样才能做到这一点?

用电子和Systemjs导入节点模块

我只是想知道是否有可能让systemjs使用require(“remote”)。require(“nodemodule”),如果系统js无法在自己的registry中find该模块? 我认为像这种机制的东西已经在使用电子与打字稿和commonjs模块工作… 有人已经解决了这个问题吗?

要求使用TypeScript,SystemJS和Electron的nodejs“child_process”

我正在研究一个简单的nodejs 电子 (以前称为primefaces壳)项目。 我正在使用angular 2编写它,使用项目相同的项目设置,他们build议在typescript的文档中: TSC: { "compilerOptions": { "target": "es5", "module": "system", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false }, "exclude": [ "node_modules", "typings/main", "typings/main.d.ts" ] } 我需要运行一个命令,我发现我可以用节点“child_process”来完成。 无论如何我无法find“导入”或“要求”,而从node.d.ts文件中使用它的types。 我在node.d.ts文件中find了适合我需要的“child_process”接口,这就是它在node.d.ts文件中的样子: declare module "child_process" { import * as events from "events"; import * as stream from "stream"; export interface ChildProcess […]

使用module = system为节点设置TypeScript不起作用

我试图设置使用打字稿的restify项目。 经过各种尝试后,我可以通过在tsconfig.json中使用“module:commonjs”创build一个工作版本 我宁愿使用系统 – 但我不能用systemjs来设置它 boot.ts import {AppServer} from './app'; var _appServer = new AppServer(); tsconfig.json { "compilerOptions": { "target": "ES5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false }, "exclude": [ "node_modules" ] } app.ts /// <reference path="typings/restify/restify.d.ts" /> import {Server, Response, Request, createServer} from 'restify'; export class […]