命令`node APIfunctions.js`编译age"/>
使用命令`node APIfunctions.js`编译age
我正在尝试使用命令为 age-viewer-go 编译 API 函数
node APIfunctions.js
文件在这里:.js
但是编译抛出这个错误:
internal/modules/cjs/loader.js:883 抛出错误; ^
错误:找不到模块'node-fetch'需要堆栈:
- /home/linux/age-viewer-Go/age-Go/backend/APIfunctions.js 在 Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) 在 Function.Module._load (internal/modules/cjs/loader.js:725:27) 在 Module.require (internal/modules/cjs/loader.js:952:19) 在要求(内部/模块/cjs/helpers.js:88:18) 在对象。 (/home/linux/age-viewer-Go/age-Go/backend/APIfunctions.js:2:15) 在 Module._compile (internal/modules/cjs/loader.js:1063:30) 在 Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) 在 Module.load (internal/modules/cjs/loader.js:928:32) 在 Function.Module._load (internal/modules/cjs/loader.js:769:14) 在 Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) { code: 'MODULE_NOT_FOUND',
要求堆栈:[ '/home/linux/age-viewer-Go/age-Go/backend/APIfunctions.js']}
可能是什么错误?
回答如下:要修复此错误,您需要通过在终端或命令提示符中运行以下命令来安装“node-fetch”模块:
npm install node-fetch
这将在项目的“node_modules”目录中安装“node-fetch”模块及其依赖项。在那之后,您应该能够运行您的代码而不会出现任何错误。
此外,此错误消息表明您正在尝试使用 require() 语句加载 ES 模块,某些版本的 Node.js 不支持该模块。所以使用任何比 14.0.0 更高的版本。具体来说,当您尝试 require() APIfunctions.js 文件中的 node-fetch 包时会发生错误。
更多推荐
使用命令`node APIfunctions.js`编译age
发布评论