9阅网

您现在的位置是:首页 > 知识 > 正文

知识

node.js - System.err: TypeError: 无法读取未定义的 split 属性。

admin2022-11-07知识15

我试图在我的模板视图中显示Twilio数据,列出所有使用Twilio API为我的账户发送的消息。所有这些都是在Nativescript-Vue中完成的。我的代码是这样的

<template>
  <Page>
    <ActionBar title="API TEST/>
      <ScrollView>
        <StackLayout>
          <StackLayout :key="message.sid" v-for="message in myMessages">
            <Label :text="message.body" />
            <Label :text="message.from" />
            <Label :text="message.to " />
          </StackLayout>
        </StackLayout>
    </ScrollView>
  </Page>
</template>

<script>
  const Twilio = require('twilio');
  const client = new Twilio("[my accountSid]","[my authToken]");

  export default {
   data() {
     return {
       myMessages: []
     }
   },

   created() {
     this.getList();
   },

   methods: 
     {
      getList() {
        client.messages
          .list()
          .then(messages => messages.forEach(m => this.myMessages.push(m))
          )
          .catch(err => console.error(err));
       }
     }
  }
</script>

当我运行 tns run android 我得到以下错误信息

System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to create application com.tns.NativeScriptApplication:com.tns.NativeScriptException: Error calling module function
System.err: TypeError: Cannot read property 'split' of undefined
System.err: File: (file:///node_modules\pbkdf2\lib\default-encoding.js:6:47)

先谢谢大家的帮助!



【回答】:

由于它发生在pbkdf2这个加密库中,我敢说这是你的Twilio认证信息的问题。确保你使用的是正确的值。

我会通过将 Twilio 代码隔离到它自己的可测试的小片段中来验证这一点。

【回答】:

看来pbkdf2中存在一些错误。default-encoding.js. 您可能需要编辑模块库

试试打开 node_modules\pbkdf2\lib\default-encoding.js:6:47 像错误建议一样,在文件的顶部添加以下内容。

var process = require('process')

如果在添加行后仍然存在错误,你可能需要在他们的github上发布一个问题。