Skip to content
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

fix: fixing "Could not find a declaration file for module 'body-parser'" Error #278

Merged
merged 1 commit into from
Aug 22, 2023

Conversation

jerryc05
Copy link
Contributor

Seems like this repo requires a type def for body-parser to work properly

$ pnpm run start

> @ory/[email protected] start ***\ory-kratos\kratos-selfservice-ui-node
> nodemon

[nodemon] 2.0.20
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): src\**\*
[nodemon] watching extensions: ts
[nodemon] starting `ts-node ./src/index.ts`
┌───────────────────────────────────┐
│ New version of nodemon available! │
│ Current Version: 2.0.20           │
│ Latest Version: 3.0.1             │
└───────────────────────────────────┘
***\ory-kratos\kratos-selfservice-ui-node\node_modules\.pnpm\[email protected]_@[email protected][email protected]\node_modules\ts-node\src\index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
src/routes/consent.ts:9:24 - error TS7016: Could not find a declaration file for module 'body-parser'. '***/ory-kratos/kratos-selfservice-ui-node/node_modules/.pnpm/[email protected]/node_modules/body-parser/index.js' implicitly has an 'any' type.  
  If the 'body-parser' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/body-parser'

9 import bodyParser from "body-parser"
                         ~~~~~~~~~~~~~

    at createTSError (***\ory-kratos\kratos-selfservice-ui-node\node_modules\.pnpm\[email protected]_@[email protected][email protected]\node_modules\ts-node\src\index.ts:859:12)
    at reportTSError (***\ory-kratos\kratos-selfservice-ui-node\node_modules\.pnpm\[email protected]_@[email protected][email protected]\node_modules\ts-node\src\index.ts:863:19)
    at getOutput (***\ory-kratos\kratos-selfservice-ui-node\node_modules\.pnpm\[email protected]_@[email protected][email protected]\node_modules\ts-node\src\index.ts:1077:36)
    at Object.compile (***\ory-kratos\kratos-selfservice-ui-node\node_modules\.pnpm\[email protected]_@[email protected][email protected]\node_modules\ts-node\src\index.ts:1433:41)
    at Module.m._compile (***\ory-kratos\kratos-selfservice-ui-node\node_modules\.pnpm\[email protected]_@[email protected][email protected]\node_modules\ts-node\src\index.ts:1617:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
    at Object.require.extensions.<computed> [as .ts] (***\ory-kratos\kratos-selfservice-ui-node\node_modules\.pnpm\[email protected]_@[email protected][email protected]\node_modules\ts-node\src\index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Function.Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19) {
  diagnosticCodes: [ 7016 ]
}
[nodemon] app crashed - waiting for file changes before starting...

The fix is:

$ git diff package.json
diff --git a/package.json b/package.json
index d3bbd15..9a7eead 100644
--- a/package.json
+++ b/package.json
@@ -43,6 +43,7 @@
   "devDependencies": {
     "@trivago/prettier-plugin-sort-imports": "4.0.0",
     "@types/axios": "0.14.0",
+    "@types/body-parser": "^1.19.2",
     "@types/cookie-parser": "1.4.3",
     "@types/csurf": "1.11.2",
     "@types/express": "4.17.17",

Related Issue or Design Document

Checklist

  • I have read the contributing guidelines and signed the CLA.
  • I have referenced an issue containing the design document if my change introduces a new feature.
  • I have read the security policy.
  • I confirm that this pull request does not address a security vulnerability.
    If this pull request addresses a security vulnerability,
    I confirm that I got approval (please contact [email protected]) from the maintainers to push the changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added the necessary documentation within the code base (if appropriate).

Further comments

@CLAassistant
Copy link

CLAassistant commented Aug 19, 2023

CLA assistant check
All committers have signed the CLA.

@jerryc05 jerryc05 changed the title Fixing "Could not find a declaration file for module 'body-parser'" bugfix: fixing "Could not find a declaration file for module 'body-parser'" Error Aug 19, 2023
@jerryc05 jerryc05 changed the title bugfix: fixing "Could not find a declaration file for module 'body-parser'" Error fix: fixing "Could not find a declaration file for module 'body-parser'" Error Aug 19, 2023
@aeneasr aeneasr merged commit 72af913 into ory:master Aug 22, 2023
5 of 7 checks passed
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

Successfully merging this pull request may close these issues.

3 participants