Skip to content

Cannot find module 'axios' in 9.3.0 #310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TommySorensen opened this issue Oct 25, 2021 · 9 comments
Closed

Cannot find module 'axios' in 9.3.0 #310

TommySorensen opened this issue Oct 25, 2021 · 9 comments

Comments

@TommySorensen
Copy link

Hi all
I am using the npx swagger-typescript-api like below to generate our types. Recently this has stopped working because of the script can't find the Axios package.

Console output:

$ npx swagger-typescript-api -p https://our-api-url/swagger/v1/swagger.json -o ./src/app/models/ -n index.ts --no-client --extract-request-params --extract-request-body
npx: installed 78 in 2.493s
Cannot find module 'axios'
Require stack:
- /Users/user/.npm/_npx/20804/lib/node_modules/swagger-typescript-api/src/swagger.js
- /Users/user/.npm/_npx/20804/lib/node_modules/swagger-typescript-api/src/index.js
- /Users/user/.npm/_npx/20804/lib/node_modules/swagger-typescript-api/index.js
error Command failed with exit code 1.

Any help is appreciated.

@DonatasD
Copy link

You could try using exact version and use previous release like this:
npx [email protected]

@TommySorensen
Copy link
Author

You could try using exact version and use previous release like this: npx [email protected]

Thx previous version works perfectly 👍

npx: installed 57 in 9.477s
✨   try to get swagger by URL "https://our-api-url/swagger/v1/swagger.json"
✨   try to read templates from directory "/Users/user/.npm/_npx/22418/lib/node_modules/swagger-typescript-api/templates/default"
☄️    start generating your typescript api
✅   typescript api file index.ts created in /Users/user/src/app/models
✨  Done in 35.66s.

I guess that means latest version has a bug somewhere. I have not looked into the source code. Does anyone else have time to look into it?

@TommySorensen TommySorensen changed the title Cannot find module 'axios' Cannot find module 'axios' in 9.2.0 Oct 25, 2021
@jeking3
Copy link

jeking3 commented Oct 25, 2021

Isn't the problem in 9.3.0? Ever since I bumped up to 9.3.0 I found I must use node14 and I must add axios myself, otherwise I get failures. With node 12, some code now uses .? which node12 does not understand:

jking@pulsar:~/truth/configure$ npm run generate-client

> [email protected] generate-client /home/jking/truth/configure
> npx swagger-typescript-api -p openapi.json -o ./src/gen --modular --responses --route-types --extract-request-params --extract-request-body

Unexpected token '.'
npm ERR! code ELIFECYCLE

Then if I use node14 or later:

jking@pulsar:~/truth/configure$ npm run generate-client

> [email protected] generate-client
> npx swagger-typescript-api -p openapi.json -o ./src/gen --modular --responses --route-types --extract-request-params --extract-request-body

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'axios'
Require stack:
- /home/jking/truth/configure/node_modules/swagger-typescript-api/src/swagger.js
- /home/jking/truth/configure/node_modules/swagger-typescript-api/src/index.js
- /home/jking/truth/configure/node_modules/swagger-typescript-api/index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/jking/truth/configure/node_modules/swagger-typescript-api/src/swagger.js:3:15)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/jking/truth/configure/node_modules/swagger-typescript-api/src/swagger.js',
    '/home/jking/truth/configure/node_modules/swagger-typescript-api/src/index.js',
    '/home/jking/truth/configure/node_modules/swagger-typescript-api/index.js'
  ]
}

I had neither of these problems with 9.2.0. The "npx" command in the original problem description is going to pull the latest which is 9.3.0 and not 9.2.0 so I think the title is wrong.

@TommySorensen
Copy link
Author

@jeking3 The latest release is named 9.2.0 https://github.com/acacode/swagger-typescript-api/releases
I'm not sure where you get the version 9.3.0 from?

@jeking3
Copy link

jeking3 commented Oct 25, 2021

https://www.npmjs.com/package/swagger-typescript-api
swagger-typescript-api
TypeScript icon, indicating that this package has built-in type declarations
9.3.0 • Public • Published 3 days ago

@TommySorensen TommySorensen changed the title Cannot find module 'axios' in 9.2.0 Cannot find module 'axios' in 9.3.0 Oct 25, 2021
@jeking3
Copy link

jeking3 commented Oct 25, 2021

Linking to #294 as this seems pretty serious.

@cipchk
Copy link
Contributor

cipchk commented Oct 28, 2021

@TommySorensen Some question in 9.3.0:

Your global Angular CLI version (12.2.8) is greater than your local version (12.2.2). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
An unhandled exception occurred: Cannot find module 'axios'
Require stack:
- /Users/cipchk/Desktop/work/ng-alain/node_modules/swagger-typescript-api/src/swagger.js
- /Users/cipchk/Desktop/work/ng-alain/node_modules/swagger-typescript-api/src/index.js
- /Users/cipchk/Desktop/work/ng-alain/node_modules/ng-alain/sta/index.js
- /Users/cipchk/Desktop/work/ng-alain/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /Users/cipchk/Desktop/work/ng-alain/node_modules/@angular-devkit/schematics/tools/index.js
- /Users/cipchk/Desktop/work/ng-alain/node_modules/@angular/cli/utilities/json-schema.js
- /Users/cipchk/Desktop/work/ng-alain/node_modules/@angular/cli/models/command-runner.js
- /Users/cipchk/Desktop/work/ng-alain/node_modules/@angular/cli/lib/cli/index.js
- /Users/cipchk/.config/yarn/global/node_modules/@angular/cli/lib/init.js
- /Users/cipchk/.config/yarn/global/node_modules/@angular/cli/bin/ng
See "/private/var/folders/gq/9pcvzdt577729qn7763c26hm0000gp/T/ng-tghXXY/angular-errors.log" for further details.

We are using Http request through custom template under Angular, I don’t think axios must be installed.

@js2me
Copy link
Member

js2me commented Oct 28, 2021

will be fixed in [email protected]

@js2me
Copy link
Member

js2me commented Oct 28, 2021

fixed in 9.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants