当试图包括node-rsa
得到:
TypeError: util.inherits is not a function.
复制步骤:
vue init nativescript-vue/vue-cli-template repro
cd repro
npm install --save node-rsa
npm install
将此行添加到HelloWorld.vue
:
<script>
从“node-rsa”导入 * 作为 NodeRSA;// 添加这一行
export default {
data () {
return {
surprise: false,
};
},
};
</script>
npm run watch:ios
得到这个错误:
***** Fatal JavaScript exception - application has been terminated. *****
Native stack trace:
1 0x104692c1f NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool, bool)
2 0x1046c7caf -[TNSRuntime executeModule:referredBy:]
3 0x10414b441 main
4 0x10a137955 start
5 0x1
JavaScript stack trace:
1 @file:///app/app.js:13604:14
2 __webpack_require__@file:///app/app.js:20:34
3 @file:///app/app.js:36341:33
4 @file:///app/app.js:36601:34
5 __webpack_require__@file:///app/app.js:20:34
6 @file:///app/app.js:36311:33
7 __webpack_require__@file:///app/app.js:20:34
8 @file:///app/app.js:9649:30
9 __webpack_require__@file:///app/app.js:20:34
10 @file:///app/app.js:27449:30
11 @file:///app/app.js:27838:34
12 __webpack_require__@file:///app/app.js:20:34
13 @file:///app/app.js:27406:35
14 __webpack_require__@file:///app/app.js:20:34
15 @file:///app/app.js:27228:176
16 __webpack_require__@file:///app/app.js:20:34
17 @file:///app/app.js:13948:38
18 __webpack_require__@file:///app/app.js:20:34
19 @file:///app/app.js:63:37
20 anonymous@file:///app/app.js:64:12
21 evaluate@[native code]
22 moduleEvaluation@[native code]
23 @[native code]
24 promiseReactionJob@[native code]
JavaScript error:
file:///app/app.js:13604:14: JS ERROR TypeError: util.inherits is not a function. (In 'util.inherits(assert.AssertionError, Error)', 'util.inherits' is an instance of Object)