【问题标题】:Require is not defined when importing @project-serum/anchor导入@project-serum/anchor 时未定义要求
【发布时间】:2022-01-02 03:50:24
【问题描述】:

我正在尝试将@project-serum/anchor 导入到 Vue 3 项目中,使用

import * as anchor from '@project-serum/anchor';

项目编译正常,但是当组件加载时会抛出错误:

VM28957:1 Uncaught (in promise) ReferenceError: require is not defined
    at eval (eval at nodeWrap (sha256.js?6c27:1), <anonymous>:1:1)
    at nodeWrap (sha256.js?6c27:83)
    at createMethod (sha256.js?6c27:67)
    at eval (sha256.js?6c27:501)
    at Object.eval (sha256.js?6c27:518)
    at eval (sha256.js:521)
    at Object../node_modules/js-sha256/src/sha256.js (3.js:1335)
    at __webpack_require__ (app.js:854)
    at fn (app.js:151)
    at Module.eval (common.js?789d:1)

【问题讨论】:

    标签: vue.js webpack


    【解决方案1】:

    我可以通过设置window.JS_SHA256_NO_NODE_JS = true来解决这个问题

    【讨论】:

      猜你喜欢
      • 2022-12-22
      • 2023-02-23
      • 2019-04-11
      • 1970-01-01
      • 2016-09-06
      • 2021-10-20
      • 2019-11-16
      • 2021-05-12
      • 2019-04-15
      相关资源
      最近更新 更多