[@sentry/node] "Cannot find name" TypeScript build errors
See original GitHub issue- Review the documentation: https://docs.sentry.io/
- Search for existing issues: https://github.com/getsentry/sentry-javascript/issues
- Use the latest release: https://github.com/getsentry/sentry-javascript/releases
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: "..."
});
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Fix the Cannot Find Name 'require' Error in TypeScript
To fix the “cannot find name 'require'” error in TypeScript, install the @types/node package into your project by running npm i -D @types/node...
Read more >How to Add Sentry to Your Node.js Project with TypeScript
Sentry.io is an external monitoring and logging service which can help you identify and triage errors in your code.
Read more >Node.js - Sentry Documentation
On this page, we get you up and running with Sentry's SDK, ... Sentry's Node SDK enables automatic reporting of errors, exceptions, and...
Read more >TypeScript getting error TS2304: cannot find name ' require'
If you are using Webpack as your build tool you can include the Webpack types. npm install --save-dev @types/webpack-env. Update your tsconfig.json with...
Read more >@sentry/node | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Aquilosion
dom
typings contain those APIs, forgot about that. Tested with your project, it works just fine. We’ll document this 😃@Aquilosion you have to add
node
typings to your project.Sorry for the inconvinience, it’ll be included in the docs. Cheers!