node.js - 类型错误 : stream is undefined

标签 node.js sqlite reactjs

无法向我的小型 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.stderrprocess.stdout 存在。就你而言,他们不是。如果您在 Electron 中运行应用程序,情况可能就是这样。

关于node.js - 类型错误 : stream is undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43898072/

相关文章:

支持 sqlite3 的 PHP

java - 如何将 SQLite 数据从 Android 发送到 MySQL 服务器?

java - Sqlite 插入无法正常工作

javascript - REACT 待办事项列表 : How to check if an item already exist in the array

javascript - 无法在 WebStorm 中使用 Spy-js 分析 Babel 转译的 Node.js 应用程序

javascript - 如何处理依赖于多个其他异步函数的异步函数

node.js - GitHub Action 中的 npm install 失败并显示 "ENOENT: no such file or directory"- 在其他地方工作正常

javascript - jstree中如何获取被点击的对象

javascript - React .map 不重新渲染

animation - React - 当项目离开 DOM 时跳跃动画