gpt4 book ai didi

node.js - 类型错误 : Cannot read property 'onReady' of undefined

转载 作者:太空宇宙 更新时间:2023-11-04 01:34:55 25 4
gpt4 key购买 nike

当我运行 node ./myapp.js 时,我得到了

(node:14122) ExperimentalWarning: The ESM module loader is experimental.
internal/modules/cjs/loader.js:637
module.reflect.onReady((reflect) => {
^

TypeError: Cannot read property 'onReady' of undefined
at Module.load (internal/modules/cjs/loader.js:637:22)
at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
at Function.Module._load (internal/modules/cjs/loader.js:558:3)
at Module.require (internal/modules/cjs/loader.js:663:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/home/ecarroll/code/sw/source-water/sw-input/node_modules/psl/index.js:14:19)
at Module._compile (internal/modules/cjs/loader.js:734:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
at Module.load (internal/modules/cjs/loader.js:626:32)
at tryModuleLoad (internal/modules/cjs/loader.js:566:12)

最佳答案

这里的关键是,

(node:14122) ExperimentalWarning: The ESM module loader is experimental.

此错误和后续类型错误

TypeError: Cannot read property 'onReady' of undefined

是由存在引起的,

NODE_OPTIONS=--experimental-modules

您应该取消定义或设置它NODE_MODULES=""Node ...

If you run Node with --experimental-modules then,

It's important to note here that .mjs isn't only about file extensions. running node with the --experimental-modules flag also means that ES6 module specifiers must be valid urls, so the extension has to be included in the import statement, e.g. import x from './x.mjs

关于node.js - 类型错误 : Cannot read property 'onReady' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54883272/

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