无法向我的小型 React 应用程序添加数据库连接,我尝试了一堆 npm 模块:sqlite、sqlite3、realm。全部因类型错误而回退:
TypeError: stream is undefined
我什么也没做,只是在我的组件中添加了一条 require 语句,出现错误:
import db from 'sqlite';
或者:
var sqlite = require('sqlite3').verbose();
最后一个跟踪字符串:
(function (process){
module.exports = function (blocking) {
[process.stdout, process.stderr].forEach(function (stream) {
if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === 'function') {
stream._handle.setBlocking(blocking)
}
})
}
真正的构建失败,错误:找不到模块“AccessibilityInfo”
最佳答案
您的最后一个跟踪指向 set-blocking
npm 模块的内容。通常由npmlog
使用。它需要 process.stderr
和 process.stdout
存在。就你而言,他们不是。如果您在 Electron 中运行应用程序,情况可能就是这样。
关于node.js - 类型错误 : stream is undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43898072/