无法使用 node-fetch 模块 (以按说明安装在client目录下)
发布于 7 年前 作者 xionggang 9619 次浏览 来自 问答

1 进入项目根目录下的client目录 npm init

2 npm install node-fetch

3 在开发工具中 -> 构建npm

4 pages/index/index.js    中引入  const fetch = require(‘node-fetch’)

出现以下错误

VM608:1 thirdScriptError 

 sdk uncaught third Error 

 module “miniprogram_npm/node-fetch/stream” is not defined 

 Error: module “miniprogram_npm/node-fetch/stream” is not defined

    at require (http://127.0.0.1:52229/appservice/__dev__/WAService.js:23:11483)

    at http://127.0.0.1:52229/appservice/__dev__/WAService.js:23:11231

    at __REQUIRE__ (http://127.0.0.1:52229/appservice/miniprogram_npm/node-fetch/index.js:17:32)

    at http://127.0.0.1:52229/appservice/miniprogram_npm/node-fetch/index.js:1805:23

    at Object.module.exports.map [as func] (http://127.0.0.1:52229/appservice/miniprogram_npm/node-fetch/index.js:50:16)

    at __REQUIRE__ (http://127.0.0.1:52229/appservice/miniprogram_npm/node-fetch/index.js:18:71)

    at http://127.0.0.1:52229/appservice/miniprogram_npm/node-fetch/index.js:1807:9

    at http://127.0.0.1:52229/appservice/miniprogram_npm/node-fetch/index.js:1808:2

    at require (http://127.0.0.1:52229/appservice/__dev__/WAService.js:23:11624)

    at http://127.0.0.1:52229/appservice/__dev__/WAService.js:23:11231

1 回复

小程序没有 node 的运行环境,因此这个模块不适用哦。请使用 wx.request。

回到顶部