logaretm / villus

🏎 A tiny and fast GraphQL client for Vue.js

Home Page:https://villus.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: Could not resolve a fetch() method, you should provide one.

jbaubree opened this issue · comments

Hello,
I'm using vite-ssg to build my vue3 app. There is no problem when i'm running pnpm build locally, but when build runs in azure pipeline, i got this error :

/home/vsts/work/1/s/node_modules/.pnpm/villus@2.0.0_graphql@16.6.0+vue@3.2.40/node_modules/villus/dist/villus.js:233
          throw new Error('Could not resolve a fetch() method, you should provide one.');
                ^
Error: Could not resolve a fetch() method, you should provide one.
    at fetch (/home/vsts/work/1/s/node_modules/.pnpm/villus@2.0.0_graphql@16.6.0+vue@3.2.40/node_modules/villus/dist/villus.js:233:17)
    at defaultPlugins (/home/vsts/work/1/s/node_modules/.pnpm/villus@2.0.0_graphql@16.6.0+vue@3.2.40/node_modules/villus/dist/villus.js:334:51)
    at new Client (/home/vsts/work/1/s/node_modules/.pnpm/villus@2.0.0_graphql@16.6.0+vue@3.2.40/node_modules/villus/dist/villus.js:340:42)
    at createClient (/home/vsts/work/1/s/node_modules/.pnpm/villus@2.0.0_graphql@16.6.0+vue@3.2.40/node_modules/villus/dist/villus.js:409:22)
    at file:///home/vsts/work/1/s/.vite-ssg-temp/main.mjs:70:16
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:533:24)
    at async build (file:///home/vsts/work/1/s/node_modules/.pnpm/vite-ssg@0.21.0_jkkq46cf6jwamxhuxi2tsturta/node_modules/vite-ssg/dist/shared/vite-ssg.8a070b5a.mjs:995:87)
    at async Object.handler (file:///home/vsts/work/1/s/node_modules/.pnpm/vite-ssg@0.21.0_jkkq46cf6jwamxhuxi2tsturta/node_modules/vite-ssg/dist/node/cli.mjs:28:5)
 ELIFECYCLE  Command failed with exit code 1.
##[error]Bash exited with code '1'.

Is there any way to fix it ?
Thanks

It was an environment issue, node was not active in my command line.