APIDevTools / swagger-parser

Swagger 2.0 and OpenAPI 3.0 parser/validator
https://apitools.dev/swagger-parser
MIT License
1.09k stars 154 forks source link

Buffer type not found when importing library into Angular project #155

Closed cjwillis809 closed 3 years ago

cjwillis809 commented 3 years ago

Hello,

I am trying to import and work with swagger-parser within a sample Angular project created with the Angular CLI. When I imported the library, I had to get around some build issues, but now I'm just facing this error everytime I try to build:

ERROR in node_modules/@apidevtools/swagger-parser/lib/index.d.ts(327,17): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try npm i @types/node and then add node to the types field in your tsconfig. node_modules/@apidevtools/swagger-parser/lib/index.d.ts(327,43): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try npm i @types/node and then add node to the types field in your tsconfig. node_modules/@apidevtools/swagger-parser/lib/index.d.ts(376,20): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try npm i @types/node and then add node to the types field in your tsconfig.

From the error, it looks like Buffer isn't being resolved at all. When I install the types for node, it still returns this error. Does anyone know what the issue could be here? I installed the latest version of swagger-parser out currently, which is 10.0.2.

I've tried the following steps before this:

  1. Installed the openapi-types package (Initially it was not installed). This removed a number of errors.
  2. Installed the @types/node package a couple times.

Any help is greatly appreciated!

cjwillis809 commented 3 years ago

I have resolved this particular error. For anyone else looking, I had to add the node types within my tsconfig.app.json file like so:


"compilerOptions": {
   ...
   "types": ["node"]

}