I've installed a js library https://www.npmjs.com/package/fft with npm, how can I make this available in node-red functions ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
This is covered towards the end of the Configuration and the Writing Functions sections of the Node-RED docs
You need to add npm modules to the settings.js
file. You can find this file in ~/.node-red/
The section you are looking for is the functionGlobalContext
section.
...
functionGlobalContext: {
fft: require('fft')
},
...
You would then access the module in the function node with the following:
var FFT = context.global.get('fft');
var fft = new FFT(n, inverse);
...
Also be careful where you installed the fft module, it needs to be either in ~/.node-red/node_modules
or installed globally so it is accessable to Node-RED