Skip to content

[@sentry/node] "Cannot find name" TypeScript build errors #1530

@Aquilosion

Description

@Aquilosion

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

4.0.0-rc.2

Description

Perhaps I've not correctly configured my TypeScript environment or something, but I cannot seem to successfully run tsc --build with @sentry/node, getting the following errors:

node_modules/@sentry/node/dist/handlers.d.ts:2:49 - error TS2304: Cannot find name 'Request'.

2 export declare function requestHandler(): (req: Request, res: Response, next: () => void) => void;
                                                  ~~~~~~~

node_modules/@sentry/node/dist/handlers.d.ts:2:63 - error TS2304: Cannot find name 'Response'.

2 export declare function requestHandler(): (req: Request, res: Response, next: () => void) => void;
                                                                ~~~~~~~~

node_modules/@sentry/node/dist/handlers.d.ts:13:71 - error TS2304: Cannot find name 'Request'.

13 export declare function errorHandler(): (error: MiddlewareError, req: Request, res: Response, next: (error: MiddlewareError) => void) => void;
                                                                         ~~~~~~~

node_modules/@sentry/node/dist/handlers.d.ts:13:85 - error TS2304: Cannot find name 'Response'.

13 export declare function errorHandler(): (error: MiddlewareError, req: Request, res: Response, next: (error: MiddlewareError) => void) => void;
                                                                                       ~~~~~~~~

node_modules/@sentry/node/dist/transports/base.d.ts:8:53 - error TS2304: Cannot find name 'URL'.

8     request(options: http.RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
                                                      ~~~

In case it is my TypeScript configuration, the contents of tsconfig.json is:

{
	"compilerOptions": {
		"module": "commonjs",
		"target": "es2017",
		"lib": [
			"es2017"
		],
		"moduleResolution": "node",
		"rootDir": "./",
		"sourceMap": true,
		"allowJs": true,
		"noImplicitAny": true,
		"noUnusedLocals": true,
		"noImplicitThis": true,
		"strictNullChecks": true,
		"noImplicitReturns": true,
		"preserveConstEnums": true,
		"suppressImplicitAnyIndexErrors": true,
		"forceConsistentCasingInFileNames": true,
		"strict": true
	},
	"exclude": [
		"node_modules",
		"build",
		"webpack"
	],
	"types": [
		"typePatches"
	]
}

And a simple use case:

import { init } from "@sentry/node";

init({
	dsn: "..."
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions