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

error TS2688: Cannot find type definition file for 'node'. #25

Open
Baoyx007 opened this issue Aug 26, 2017 · 5 comments
Open

error TS2688: Cannot find type definition file for 'node'. #25

Baoyx007 opened this issue Aug 26, 2017 · 5 comments

Comments

@Baoyx007
Copy link

RROR in /Users/**/learning-rxjs/tsconfig.json
error TS2688: Cannot find type definition file for 'node'.

切换成 seed 分支无法运行, master 分支是可以的

@dyh333
Copy link

dyh333 commented Dec 20, 2017

same issue @Brooooooklyn
node -v : v6.12.0

@Brooooooklyn
Copy link
Owner

是使用 yarn 进行安装的吗

@dyh333
Copy link

dyh333 commented Dec 21, 2017

用yarn和npm都试过 均会报错 @Brooooooklyn

@pfncfen
Copy link

pfncfen commented Mar 19, 2018

这个问题我也遇到了 是在win10环境下 升级了node版本等等操作均无效
然后google到了这个地址 https://github.com/Microsoft/TypeScript/issues/16772

依照refer的issue,问题可能出在多个方面:

  1. tsconfig.json里的配置有问题
    "typeRoots": [ "./node_modules/@types" ], "types": [ "node", "jquery" ] }, "exclude": [ "node_modules" ],
    typeRoots里的项 可在前面加../,保证能搜到该目录
    types数组项里要有node这一项,后续的exclude里要去处node_modules目录
    这条对我无效,但是原文里有人因为改了这个,生效了。

  2. 将ts-loader更换为awesome-typescript-loader
    原文里提到可能是ts-loader的问题,所以我更换了以后 问题成功解决 编译成功

操作方法:

  1. 在目录下执行yarn add awesome-typescript-loader --dev
  2. 在webpack.config.js里,找到loaders数组,将ts的loader改为如下模式
    { test: /\.ts$/, loader: 'awesome-typescript-loader' },
    然后就可以正常编译了
@DevinXian
Copy link

DevinXian commented Jul 6, 2018

The version of ts-loader is too old, please check ts-loader@2.3.0 or newer. ts-loader@4.x that need webpack@4.x doesn't work as well @Brooooooklyn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants