调用npm模块

注:jmms使用的nashorn引擎只能执行不依赖node环境的js.

下面以underscore为例演示如何在jmms中调用npm管理的node模块。

初始化npm工程

进入app目录

$ npm init

安装underscore module

$ npm install --save underscore

安装后underscore保存在在app/node_modules目录中。

调用underscore module

js中直接调用即可:

function _() {
    const _ = require('underscore');
    const i = _.first([5,4,3,2,1]);
    //...
}
Bingosoft            updated 2018-07-23
上一篇:调用模块 下一篇:数据访问

results matching ""

    No results matching ""