Skip to content

"Cannot find type definition file for 'node'." for 2.4.1 #16772

Closed

Description

TypeScript Version: 2.4.1

Code

https://github.com/Mercateo/ws/tree/v2

Diff yarn.lock:

typescript@^2.3.4:
-  version "2.4.0"
-  resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.0.tgz#aef5a8d404beba36ad339abf079ddddfffba86dd"
+  version "2.4.1"
+  resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.1.tgz#c3ccb16ddaa0b2314de031e7e6fee89e5ba346bc"
$ yarn
$ npm run build

Expected behavior:

Compile.

Actual behavior:

ERROR in /Users/foo/Workspace/mercateo-ws/tsconfig.json
error TS2688: Cannot find type definition file for 'node'.

Activity

  1. andykellr commented on Jun 27, 2017

    @andykellr

    We are having the same problem, but it only seems to surface when running mocha with --require ts-node/register. Rolling back to 2.3.4 and will watch this issue.

  2. sgmccli commented on Jun 27, 2017

    @sgmccli

    Same issue here with ts-node/register. Fails to find all imported Types (@types) modules. I have reverted back to 2.3.4.

  3. JnelsonEmarketer commented on Jun 27, 2017

    @JnelsonEmarketer

    Ditto

  4. johntran commented on Jun 27, 2017

    @johntran

    I've been debugging for the past 2.5 hours. Thank you for this issue. I was going insane.

  5. RobARichardson commented on Jun 28, 2017

    @RobARichardson

    Having the same issue, but for several other type definition files including angular, angular-material, and more. Had to revert back to 2.3.4.

  6. JasonKleban commented on Jun 28, 2017

    @JasonKleban

    I think this is also an issue with ts-loader. 'tsc -p .' works fine but as of this upgrade, webpack with ts-loader involved fails like this:

    ts-loader: Using typescript@2.4.1 and C:\Users\Jason\Repos\...\tsconfig.json
    Hash: 193ab870329ba77c54cf
    Version: webpack 2.5.0
    Time: 18597ms
                                   Asset     Size  Chunks                    Chunk Names
                                  app.js  2.41 MB       0  [emitted]  [big]  main
                              app.js.map  2.88 MB       0  [emitted]         main
    ...
      [69] ./src/Components/Today/Today.tsx 10.6 kB {0} [built]
    ...
     [380] ./src/Index.tsx 7.8 kB {0} [built]
        + 368 hidden modules
    
    ERROR in C:\Users\Jason\Repos\...\tsconfig.json
    error TS2688: Cannot find type definition file for 'node'.
    
    ERROR in C:\Users\Jason\Repos\...\tsconfig.json
    error TS2688: Cannot find type definition file for 'qrcode'.
    

    (which is kinda weird because it looks like it built everything successfully before it errors out with this??)

    Rolling back to 2.3.4 and the problem is gone.

  7. teppeis commented on Jun 28, 2017

    @teppeis
  8. lkc0987 commented on Jun 28, 2017

    @lkc0987

    Having similar issues with type definitions. (node, jquery...)

    enforced typescript version 2.4.0 using npm-shrinkwrap as a workaround

    build	27-Jun-2017 19:40:29	ERROR in ./src/main/resources/static/js/modules/InfoModule.ts
    build	27-Jun-2017 19:40:29	(26,45): error TS2304: Cannot find name 'require'.
    build	27-Jun-2017 19:40:29	
    build	27-Jun-2017 19:40:29	ERROR in ./src/main/resources/static/js/common/Helper.ts
    build	27-Jun-2017 19:40:29	(4,17): error TS2503: Cannot find namespace 'Cookies'.
    build	27-Jun-2017 19:40:29	
    .....
    build	27-Jun-2017 19:40:29	ERROR in /var/......./webapp/tsconfig-prod.json
    build	27-Jun-2017 19:40:29	error TS2688: Cannot find type definition file for 'handlebars'.
    
  9. ldrick commented on Jun 28, 2017

    @ldrick

    Having same issues with all of our type definitions, which are:

    ERROR in [censored]/tsconfig.json
    error TS2688: Cannot find type definition file for 'amcharts'.
    
    ERROR in [censored]/tsconfig.json
    error TS2688: Cannot find type definition file for 'fs-extra'.
    
    ERROR in [censored]/tsconfig.json
    error TS2688: Cannot find type definition file for 'handlebars'.
    
    ERROR in [censored]/tsconfig.json
    error TS2688: Cannot find type definition file for 'highlight.js'.
    
    ERROR in [censored]/tsconfig.json
    error TS2688: Cannot find type definition file for 'jasmine'.
    
    ERROR in [censored]/tsconfig.json
    error TS2688: Cannot find type definition file for 'jquery'.
    
    ERROR in [censored]/tsconfig.json
    error TS2688: Cannot find type definition file for 'lodash'.
    
    ERROR in [censored]/tsconfig.json
    error TS2688: Cannot find type definition file for 'marked'.
    
    ERROR in [censored]/tsconfig.json
    error TS2688: Cannot find type definition file for 'minimatch'.
    
    ERROR in [censored]/tsconfig.json
    error TS2688: Cannot find type definition file for 'node'.
    
    ERROR in [censored]/tsconfig.json
    error TS2688: Cannot find type definition file for 'shelljs'.
    
    ERROR in [censored]/tsconfig.json
    error TS2688: Cannot find type definition file for 'webpack-env'.
    
  10. dashmug commented on Jun 28, 2017

    @dashmug

    Same problem here.

  11. skseth commented on Jun 28, 2017

    @skseth

    I had similar problems with ts-node, but tsc -p was fine. Upgrading to v3.1.0 fixed the problem.

  12. 26 remaining items

  13. stephen commented on Jun 28, 2017

    @stephen

    Samuel Martins (@samwx) - I think this is a separate, unrelated change: #16472

  14. samwx commented on Jun 28, 2017

    @samwx

    stephen (@stephen) Wow, that's true. Seems that typescript not supports imports like @types/... anymore. Thank you!

  15. virtustilus commented on Jul 11, 2017

    @virtustilus

    Reverted typescript from version 2.4.1 to 2.2.2 in package.json:
    "typescript": "2.2.2",
    and works fine now

  16. sluukkonen commented on Aug 21, 2017

    @sluukkonen

    For what it's worth, upgrading ts-node to the latest version seems to fix this issue for me.

  17. serbanghita commented on Sep 20, 2017

    @serbanghita

    For TypeScript 2.4.2 if you already have some custom "typeRoots": [ ... ] defined into your tsconfig.json and in your package.json you also are including "@types/node" and you work with the standard node functions like require, you will receive the error: Cannot find type definition file for 'node'.

    You need to add ./node_modules/@types/ to your typeRoots array! see docs

    Backstory: I had this problem because I use WebStorm IDE which uses tsc to compile the project, and webpack to compile it separately. Suddenly after removing some 3rd party node packages that I had I started having the above error. Now it's all good again.

  18. vinz243 commented on Sep 26, 2017

    @vinz243

    Serban Ghita (@serbanghita) you are the MVP here. Just note that the ./node_modules/@types/is relative to the directory where the tsconfig.json file is

  19. bennycode commented on Sep 27, 2017

    @bennycode
    Contributor

    I have a TypeScript app which imports another TypeScript app and I am receiving error TS2688: Cannot find type definition file for 'node'. from my imported module:

    ode_modules/wire-webapp-cryptobox/dist/typings/wire-webapp-cryptobox.d.ts(18,23): error TS2688: Cannot find type definition file for 'node'.

    I checked wire-webapp-cryptobox.d.ts(18,23) and it's this statement:
    /// <reference types="node" />

    The config of "wire-webapp-cryptobox.d.ts" looks as follows:

    {
      "compilerOptions": {
        "declaration": false,
        "lib": ["es7", "dom"],
        "module": "commonjs",
        "moduleResolution": "node",
        "noEmitOnError": true,
        "noImplicitAny": false,
        "noImplicitReturns": true,
        "removeComments": true,
        "sourceMap": false,
        "target": "es5"
      },
      "exclude": [
        "bower_components",
        "node_modules",
        "typings/browser",
        "typings/browser.d.ts"
      ]
    }

    Can you tell me where I need to set typeRoots to fix the error?

  20. Thaina commented on Jan 22, 2018

    @Thaina

    I got this error with javascript triple slash reference too

    image

    I try to reference the global node module. Is it not possible?

  21. locked and limited conversation to collaborators on Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExternalRelates to another program, environment, or user action which we cannot control.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions