Skip to content

Incompatible with recent typescript / nodejs #2

@mlocati

Description

@mlocati

When I try to build with npm install && npm run build from the current main (at 822ed3e) I have the following errors:

$ npm install && npm run build

> concretecms-mcp@1.0.0-alpha.1 build
> tsc

src/auth/oauthFlow.ts:2:30 - error TS2307: Cannot find module 'http' or its corresponding type declarations.

2 import { createServer } from 'http'
                               ~~~~~~

src/auth/oauthFlow.ts:3:22 - error TS2307: Cannot find module 'child_process' or its corresponding type declarations.

3 import { exec } from 'child_process'
                       ~~~~~~~~~~~~~~~

src/auth/oauthFlow.ts:26:20 - error TS2503: Cannot find namespace 'NodeJS'.

26     let timeoutId: NodeJS.Timeout
                      ~~~~~~

src/auth/oauthFlow.ts:28:44 - error TS7006: Parameter 'req' implicitly has an 'any' type.

28     const httpServer = createServer(async (req, res) => {
                                              ~~~

src/auth/oauthFlow.ts:28:49 - error TS7006: Parameter 'res' implicitly has an 'any' type.

28     const httpServer = createServer(async (req, res) => {
                                                   ~~~

src/auth/oauthFlow.ts:119:36 - error TS2503: Cannot find namespace 'NodeJS'.

119     httpServer.on('error', (error: NodeJS.ErrnoException) => {
                                       ~~~~~~

src/auth/oauthFlow.ts:142:24 - error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

142       const platform = process.platform
                           ~~~~~~~

src/auth/oauthFlow.ts:153:22 - error TS7006: Parameter 'error' implicitly has an 'any' type.

153       exec(command, (error) => {
                         ~~~~~

src/env.ts:1:30 - error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

1 export const canonical_url = process.env.CONCRETE_CANONICAL_URL;
                               ~~~~~~~

src/env.ts:2:26 - error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

2 export const client_id = process.env.CONCRETE_API_CLIENT_ID;
                           ~~~~~~~

src/env.ts:3:30 - error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

3 export const client_secret = process.env.CONCRETE_API_CLIENT_SECRET;
                               ~~~~~~~

src/env.ts:4:22 - error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

4 export const scope = process.env.CONCRETE_API_SCOPE;
                       ~~~~~~~

src/index.ts:5:3 - error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

5   process.exit(1)
    ~~~~~~~

src/paths.ts:1:31 - error TS2307: Cannot find module 'url' or its corresponding type declarations.

1 import { fileURLToPath } from 'url'
                                ~~~~~

src/paths.ts:2:31 - error TS2307: Cannot find module 'path' or its corresponding type declarations.

2 import { dirname, join } from 'path'
                                ~~~~~~

src/tokenStore.ts:1:57 - error TS2307: Cannot find module 'fs' or its corresponding type declarations.

1 import { existsSync, readFileSync, writeFileSync } from 'fs'
                                                          ~~~~


Found 16 errors in 5 files.

Errors  Files
     8  src/auth/oauthFlow.ts:2
     4  src/env.ts:1
     1  src/index.ts:5
     2  src/paths.ts:1
     1  src/tokenStore.ts:1

I think because of recent typescrypt/nodejs versions (I'm using node 24.14.0).

This should be fixed by

  1. adding @types/node to the devDependencies section of package.json
  2. changing tsconfig.json like this:
       "compilerOptions": {
         "target": "ES2022",
    -    "module": "ES2022",
    +    "module": "node16",
    -    "moduleResolution": "Node",
    +    "moduleResolution": "node16",
         "strict": true,
         "esModuleInterop": true,
         "forceConsistentCasingInFileNames": true,

These changes require having nodejs 16+.
This can be enforced by adding these lines to package.json:

  "engines": {
    "node": ">=16"
  },

and adding the file .npmrc with this contents:

engine-strict=true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions