问题描述
nodejs要写一个post请求,用到了axios,但是在编译的时候报了如下错误:
Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/index.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/axios.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/utils.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/bind.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/core/Axios.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/core/mergeConfig.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/defaults/index.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/formDataToJSON.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/cancel/CanceledError.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/cancel/CancelToken.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/cancel/isCancel.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/env/data.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/toFormData.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/core/AxiosError.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/spread.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/isAxiosError.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/core/AxiosHeaders.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/adapters/adapters.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/HttpStatusCode.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/buildURL.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/core/InterceptorManager.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/core/dispatchRequest.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/core/buildFullPath.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/validator.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/defaults/transitional.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/toURLEncodedForm.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/platform/index.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/platform/node/classes/FormData.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/parseHeaders.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/adapters/http.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/adapters/xhr.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/AxiosURLSearchParams.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/core/transformData.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/isAbsoluteURL.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/combineURLs.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/platform/node/index.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/core/settle.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/fromDataURI.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/AxiosTransformStream.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/formDataToStream.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/readBlob.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/callbackify.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/cookies.jsx
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/isURLSameOrigin.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/parseProtocol.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/speedometer.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/platform/node/classes/URLSearchParams.js
> Warning Failed to make bytecode node18-x64 for file /snapshot/xxx/node_modules/axios/lib/helpers/throttle.js
问题分析
是axios和pkg版本对应的问题,我的pkg是5.8.1,最开始安装的axios版本是1.7.7,nodejs版本是20.18.0
问题解决
更换axios版本为0.27.0
解决步骤:
1.npm list axios 查询axios版本
2.删除node_modules中的axios
3.pm list axios查询是否正确删除
4.npm install axios@0.27.0 --save 安装axios
5.重新npm run local 问题解决
备用命令
npm list axios
npm install axios@0.27.0 --save
npm run local
参考