简体   繁体   English

TS2688:找不到安装了@ types / node的“ node”的类型定义文件

[英]TS2688: Cannot find type definition file for 'node' with @types/node installed

I'm having a difficult time building a TypeScript application on Heroku. 我在Heroku上构建TypeScript应用程序时遇到了困难。

My dependencies list includes a type definition for all of the packages I'm using: 我的依赖项列表包括我正在使用的所有软件包的类型定义:

"dependencies": {
    "@nestjs/common": "^4.5.1",
    "@nestjs/core": "^4.5.1",
    "@nestjs/microservices": "^4.5.1",
    "@nestjs/testing": "^4.5.1",
    "@nestjs/websockets": "^4.5.1",
    "@types/express": "^4.0.39",
    "@types/jest": "^21.1.8",
    "@types/json-schema": "^6.0.0",
    "@types/jsonwebtoken": "^7.2.5",
    "@types/mongoose": "^4.7.29",
    "@types/node": "^8.5.1",
    "@types/passport": "^0.4.2",
    "@types/passport-jwt": "^3.0.0",
    "@types/supertest": "^2.0.4",
    "chalk": "^2.3.0",
    "dotenv": "^4.0.0",
    "express-jwt": "^5.3.0",
    "global": "^4.3.2",
    "jsonwebtoken": "^8.1.0",
    "mongoose": "^4.13.7",
    "passport": "^0.4.0",
    "passport-jwt": "^3.0.1",
    "redis": "^2.8.0",
    "reflect-metadata": "^0.1.10",
    "rxjs": "^5.5.5",
    "tslint": "^5.8.0",
    "ts-node": "^4.0.2",
    "typescript": "^2.6.2"
  },

However, when building on Heroku, I get: 但是,在Heroku上构建时,我得到:

error TS2688: Cannot find type definition file for 'node'
error TS2307: Cannot find module 'http'

and more. 和更多。 My tsconfig.json sets the typeRoots as './node_modules/@types' and I get a successful build locally. 我tsconfig.json设置typeRoots'./node_modules/@types' ,我得到当地一个成功的构建。

Why can't Heroku find these types? 为什么Heroku无法找到这些类型?

Apparently Heroku wasn't picking up changes to my package.json file or had cached some portion of the build process that was excluding @type definitions that I had moved from devDependencies to dependencies. 显然,Heroku并未对我的package.json文件进行更改,或者缓存了构建过程的某些部分,该部分不包括我从devDependencies移到依赖项的@type定义。

I cleared the build cache as such: 我这样清除了构建缓存:

$ heroku plugins:install heroku-repo
$ heroku repo:purge_cache -a [appname]
$ git commit --allow-empty -m "Purge cache"
$ git push heroku master

and everything works as expected. 一切都按预期进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Elastic Beanstalk“错误 TS2688:找不到‘节点’的类型定义文件。” - Elastic Beanstalk "error TS2688: Cannot find type definition file for 'node'." “找不到‘async’的类型定义文件。TS2688” - "Cannot find type definition file for 'async'. TS2688" ../node_modules/ng2-ckeditor/ckbutton 中的错误。 指令.d.TS:1:23 - 错误 TS2688:找不到“ckeditor”的类型定义文件 - ERROR in ../node_modules/ng2-ckeditor/ckbutton. directive.d.TS: 1:23 - error TS2688: Cannot find type definition file for 'ckeditor' 打字稿错误TS2688:找不到“ .AppleDouble”的类型定义文件 - Typescript error TS2688: Cannot find type definition file for '.AppleDouble' 在 heroku 节点上编译 ts-jest types-找不到类型定义 - Compile on heroku node ts- jest types- cannot find type definition 构建:找不到“节点”的类型定义文件 - Build:Cannot find type definition file for 'node' 找不到“节点”的类型定义文件 - Cannot find type definition file for 'node' npm install => 找不到“节点”的类型定义文件 - npm install => Cannot find type definition file for 'node' ts-node 找不到我的类型定义文件 - ts-node can't find my type definition files 即使安装了@types/node,Typescript 也找不到模块“fs” - Typescript Cannot find Module "fs" even though @types/node installed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM