NervJS / taro

开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
https://docs.taro.zone/
Other
35.7k stars 4.79k forks source link

使用axios报错 #649

Closed sma2lbao closed 6 years ago

sma2lbao commented 6 years ago

问题描述 使用axios报错

复现步骤 [复现问题的步骤]

  1. 引入axios
  2. 调用axios

[或者可以直接贴源代码,能贴文字就不要截图]

拷贝  NPM文件   dist/npm/axios/lib/adapters/xhr.js
{ Error: ENOENT: no such file or directory, open 'http'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at recursiveRequire (/Users/sma2lbaolee/sma2lbao/taro/io.sma2lbao.sooin/node_modules/_@tarojs_cli@1.0.1@@tarojs/cli/src/util/resolve_npm_files.js:134:24)
    at resolveNpmFilesPath (/Users/sma2lbaolee/sma2lbao/taro/io.sma2lbao.sooin/node_modules/_@tarojs_cli@1.0.1@@tarojs/cli/src/util/resolve_npm_files.js:61:5)
    at CallExpression (/Users/sma2lbaolee/sma2lbao/taro/io.sma2lbao.sooin/node_modules/_@tarojs_cli@1.0.1@@tarojs/cli/src/util/resolve_npm_files.js:103:33)
    at NodePath._call (/Users/sma2lbaolee/sma2lbao/taro/io.sma2lbao.sooin/node_modules/_babel-traverse@6.26.0@babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (/Users/sma2lbaolee/sma2lbao/taro/io.sma2lbao.sooin/node_modules/_babel-traverse@6.26.0@babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (/Users/sma2lbaolee/sma2lbao/taro/io.sma2lbao.sooin/node_modules/_babel-traverse@6.26.0@babel-traverse/lib/path/context.js:105:12)
    at TraversalContext.visitQueue (/Users/sma2lbaolee/sma2lbao/taro/io.sma2lbao.sooin/node_modules/_babel-traverse@6.26.0@babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitSingle (/Users/sma2lbaolee/sma2lbao/taro/io.sma2lbao.sooin/node_modules/_babel-traverse@6.26.0@babel-traverse/lib/context.js:108:19) errno: -2, code: 'ENOENT', syscall: 'open', path: 'http' }

期望行为 正常发送请求

报错信息

Uncaught (in promise) TypeError: adapter is not a function at dispatchRequest (dispatchRequest.js:48) at

系统信息

补充信息 [可选] [根据你的调查研究,出现这个问题的原因可能在哪里?]

1ess commented 6 years ago

@sma2lbao 请问这个是什么问题导致的?解决了吗

sma2lbao commented 6 years ago

@GodzzZZZ 我换了请求库flyio,axios在小程序端不适配。