gpt4 book ai didi

javascript - Uncaught ReferenceError : require is not defined (javascript)

转载 作者:行者123 更新时间:2023-11-30 14:35:58 26 4
gpt4 key购买 nike

因此,我正在尝试将 Node 模块与 JavaScript 结合使用,为此,我需要使用“require”加载模块,所以我像这样安装了 Require.js:

npm i requirejs

这是我的代码:

var ecurve = require('ecurve') ;
var BigInteger = require('bigi')
var AES = require("crypto-js/aes");
var SHA256 = require("crypto-js/sha256");
var CryptoJS = require("crypto-js");

但是,我总是得到这个错误:

require is not defined 

我试过 Browserify 并解决了问题,但我需要另一个没有 Browserify 的解决方案。有什么想法吗?

最佳答案

这将帮助您:

RequireJS is a JavaScript file and module loader. It is optimized for in-browser use, but it can be used in other JavaScript environments, like Rhino and Node. Using a modular script loader like RequireJS will improve the speed and quality of your code.

IE 6+ .......... compatible ✔
Firefox 2+ ..... compatible ✔
Safari 3.2+ .... compatible ✔
Chrome 3+ ...... compatible ✔
Opera 10+ ...... compatible ✔

http://requirejs.org/docs/download.html

将此添加到您的项目中:download_me

请通过require.js docs .

关于javascript - Uncaught ReferenceError : require is not defined (javascript),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50426233/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com