javascript - 在 Node.js 中导入模块失败

标签 javascript node.js node-modules

我正在尝试导入mathquill4quill使用 require 函数。该包已添加到依赖项并自动添加到 package-lock文件,所以我认为一切都很好,但是当我尝试导入这个模块时,我得到

Error: Cannot find module 'mathquill4quill'.

package.json 文件和 package-lock.json 是:

"dependencies":{
    "mathquill4quill": "latest"
}

"mathquill4quill": {
      "version": "0.1.3",
      "resolved": "https://registry.npmjs.org/mathquill4quill/-/mathquill4quill-0.1.3.tgz",
      "integrity": "sha512-/1lWllV228K2peFBJCPOU/PZaciPtq6mXIp+b78ZrLscow3ZquPLeuA8UjMoxbooJrWdRTXr2DBQMBFyNVwxYw=="
    }

如何解决?

编辑:

导入代码是:

index.html

<script src="bundle.js"></script>

bundle.js

(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){


var Quill = require('quill');
var mathquill = require('mathquill4quill');

}

// code
)

第一个函数用于检查导入是否存在

最佳答案

尝试将: var Quill = require('quill'); var mathquill = require('mathquill4quill');

高于你的功能而不是低于

关于javascript - 在 Node.js 中导入模块失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59233759/

相关文章:

node.js - 令人困惑的 NODE_MODULE 错误

javascript - 通过 Twilio npm 包发送短信 - 错误找不到 - 错误 : Cannot find module './webhooks'

JavaScript 数组语法

javascript - DOMNodeInserted 或 hashchange

c# - 从 MVC Controller 返回 Json 但日期格式在 javascript 中不正确

javascript - NPM Oracle : Inserting BLOBs

node.js - 如何在 node-pg-migrate 迁移中插入记录?

javascript - 使用 mongodb Nodejs 进行异步循环

javascript - Node.js mysql 连接仅在使用命令提示符执行时有效

npm 3.10.10安装socket挂起报错