调用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]);
//...
}