apollographql / apollo-tooling

✏️ Apollo CLI for client tooling (Mostly replaced by Rover)
https://apollographql.com
MIT License
3.04k stars 468 forks source link

cannot find module error for apollo-cli 2.33.{6,7,8,9} #2415

Open chenrui333 opened 3 years ago

chenrui333 commented 3 years ago

When I was trying to upgrade the formula to use the latest 2.33.6 release, it looks like the apollo command does not work anymore.

$ /usr/local/Cellar/apollo-cli/2.33.6/bin/apollo client:check
    Error: Cannot find module
    'graphql/validation/rules/KnownArgumentNamesRule'
    Require stack:
    - /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
    /node_modules/@apollo/federation/dist/composition/validate/preNormali
    zation/tagDirective.js
    - /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
    /node_modules/@apollo/federation/dist/composition/validate/preNormali
    zation/index.js
    - /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
    /node_modules/@apollo/federation/dist/composition/validate/index.js
    -
    /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo/n
    ode_modules/@apollo/federation/dist/composition/composeAndValidate.js
    - /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
    /node_modules/@apollo/federation/dist/composition/index.js
    - /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
    /node_modules/@apollo/federation/dist/index.js
    - /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
    /node_modules/apollo-language-server/lib/providers/schema/file.js
    - /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
    /node_modules/apollo-language-server/lib/providers/schema/index.js
    - /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
    /node_modules/apollo-language-server/lib/project/base.js
    - /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
    /node_modules/apollo-language-server/lib/index.js
    - /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
    /lib/Command.js
    - /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
    /lib/commands/client/check.js
    - /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
    /node_modules/@oclif/config/lib/plugin.js
    - /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
    /node_modules/@oclif/config/lib/config.js
    - /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
    /node_modules/@oclif/config/lib/index.js
    - /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
    /node_modules/@oclif/command/lib/command.js
    - /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
    /node_modules/@oclif/command/lib/index.js
    - /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
    /bin/run
    Code: MODULE_NOT_FOUND

relates to https://github.com/Homebrew/homebrew-core/pull/83152

jose-ibh commented 2 years ago

anybody tried this on an arm64/M1? solutions from above didn't work for me.

@sescotti I use M1 and this solution worked for me https://github.com/apollographql/apollo-tooling/issues/2415#issuecomment-998920583

harakka commented 2 years ago

Rover CLI doesn't support codegen yet

From what I understand it isn't going to. Apollo recommends graphql-code-generator but I believe it doesn't cover quite every use case.

jalalmanafi commented 2 years ago

Hi everyone , i had a same issue , just changed NODE version from 18 to 14 , it is worked for me , but i think this is not optimal way

enBonnet commented 2 years ago

Hi everyone , i had a same issue , just changed NODE version from 18 to 14 , it is worked for me , but i think this is not optimal way

Did you try this? https://github.com/apollographql/apollo-tooling/issues/2415#issuecomment-1190682198

jalalmanafi commented 2 years ago

Hi everyone , i had a same issue , just changed NODE version from 18 to 14 , it is worked for me , but i think this is not optimal way

Did you try this? #2415 (comment)

Honestly not , cause it i used this at tutorial , when i will need this at real project i will search for real solutions :)

whitewaterdesign commented 2 years ago

Thanks for the above...the following worked for me...

RUN npm install -g apollo@2.34.0 graphql@16.6.0

running from Docker

FROM node:16.17.0
RUN npm install -g npm@8.15.0
chenrui333 commented 1 year ago

This repo has been deprecated (see this comment)

thril commented 1 year ago

Another workaround if you only use the apollo service:* commands is switching to Apollo Rover because these commands are deprecated in Apollo CLI.

This was the solution that worked for me. Once I included the deprecated apollo package as a dependency, that caused the unzipped AWS lambda to be too large. Using the @apollo/rover dev dependency worked without problems.

// before ❌
npx apollo service:push <options>

// after ✅
rover subgraph publish <options>
Mpilo-Pillz commented 1 year ago

Thank you @sergpetrov your solution to install graphql globally worked perfectly for me too npm install -g graphql

Nataraj-gn commented 1 year ago

Below solution worked for me https://www.appsloveworld.com/nodejs/100/127/error-cannot-find-module-graphql-validation-rules-possibletypeextensions we just need to run sudo npm install -g graphql

tezqa commented 12 months ago

This worked for me:

"engines": {
  "node": ">=16"
},
"dependencies": {
  "graphql": "^16.8.1"
},
"devDependencies": {
  "apollo": "2.33.4",
  "apollo-language-server": "1.26.3"
}
GIHAA commented 9 months ago

npm install -g graphql and npm install -g apollo worked for me

LinusU commented 8 months ago

A super hacky way to run apollo@2 schema:download using npx today:

  1. Run npx apollo@2 schema:download and observe the path in the error
    • e.g. /Users/foobar/.npm/_npx/XXXXXXXXXXXXXXXX
  2. Switch to this directory and install specific versions of packages
    • cd /Users/foobar/.npm/_npx/XXXXXXXXXXXXXXXX
    • npm install apollo@2.33.4 apollo-codegen-core@0.40.3 apollo-language-server@1.26.3
  3. npx apollo@2 schema:download should now work 🎉
julien-vu commented 8 months ago

Apollo does not provide a schema download in the latest v3? I did not follow and I am still on the trick of using the v2

smyrick commented 5 months ago

Apollo does not provide a schema download in the latest v3? I did not follow and I am still on the trick of using the v2

Correct, that functionality was moved to our more capable CLI, Rover, which has a command rover graph introspect

avalevich commented 1 month ago

Will this be fixed before GTA 6?