将pubnub节点sdk添加到我的本机脚本项目中
npm install pubnub
我收到以下错误消息:
> System.err: Error: Parsing XML at 58:9 System.err: > util.inherits is
> not a function
我只需要这样:
const PubNub = require("pubnub");
知道这怎么可能吗?
答案 0 :(得分:0)
当前,PubNub Node SDK与NativeScript v5不兼容。它与NativeScript v3兼容。 PubNub正在研究可以与NativeScript v5兼容的更改。
@Jon_not_doe_xx的解决方法:
在webpack.config.js
文件中,将此添加到头部:
const shims = require('nativescript-nodeify/shims.json');
const aliases = {};
for (const key of Object.keys(shims)) {
const value = shims[key];
aliases[key + '$'] = value;
}
aliases['inherits$'] = 'inherits/inherits_browser';
// Remove hook, as this will only cause problems at this point.
// Checking and deleting within webpack ensures
// that it will be deleted during a cloud build.
let fs = require("fs");
let process = require("process");
if (fs.existsSync(__dirname + "/hooks/after-prepare/nativescript-nodeify.js")) {
process.stdout.write("Found evil hook, deleting...\n");
fs.unlinkSync(__dirname + "/hooks/after-prepare/nativescript-nodeify.js");
process.stdout.write("Should be fixed now.\n");
}
else process.stdout.write("Hooks seem clean, moving on.\n");
此外,修改webpack.config.js
文件中resolve对象内的别名对象:
alias: {
'~': appFullPath,
'@': appFullPath,
...aliases
},