What are you trying to achieve?
Run npx codeceptjs check with the GraphQL helper configured.
What do you get instead?
CodeceptJS throws an error claiming axios is not installed, even though it is present in node_modules.
Error: Required modules are not installed.
RUN: [sudo] npm install -g axios
at checkHelperRequirements (.../node_modules/codeceptjs/lib/container.js:434:13)
at .../node_modules/codeceptjs/lib/container.js:370:15
Root cause:GraphQL.js uses require('axios') inside _checkRequirements(), but since CodeceptJS 4 is ESM, require is not defined. This causes the catch block to always trigger and incorrectly report axios as missing.
// node_modules/codeceptjs/lib/helper/GraphQL.jsstatic_checkRequirements(){try{require('axios')// ❌ require is not defined in ESM context}catch(e){return['axios']// always returns this, even when axios IS installed}}Suggested fix:
static_checkRequirements(){// axios is already imported at the top of this ESM file,// so no runtime check is needed herereturnnull}Details
- CodeceptJS version: 4.0.8
- NodeJS Version: v20.20.2
- Operating System: Windows 11 Pro
- puppeteer || webdriverio || protractor || testcafe version (if related): Playwright 1.39.0
- Configuration file:
helpers: {GraphQL: {endpoint: 'https://rickandmortyapi.com/graphql',},}
What are you trying to achieve?
Run
npx codeceptjs checkwith theGraphQLhelper configured.What do you get instead?
CodeceptJS throws an error claiming
axiosis not installed, even though it is present innode_modules.Root cause:
GraphQL.jsusesrequire('axios')inside_checkRequirements(), but since CodeceptJS 4 is ESM,requireis not defined. This causes thecatchblock to always trigger and incorrectly reportaxiosas missing.Suggested fix:
Details