【问题标题】:TypeScript cannot find name 'NodeJS'TypeScript 找不到名称“NodeJS”
【发布时间】:2018-08-29 04:20:07
【问题描述】:

我正在使用iot-dsa JS sdk angular4 和nodejs 开发一个webApp。我的app.component.js 看起来像:

import { Component } from '@angular/core';
import { LinkProvider } from 'dslink';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app';
  link = new LinkProvider(['http://127.0.0.1:8080/conn'],
  'RequesterExample-', {
    isRequester: true,
    isResponder: false
  });

  res = this.link.connect().then(function() {
    return this.link.onRequesterReady;
  }).then(function(requester) {
     // work with requester here  
  });
}

使用ng build 构建代码时出现此错误:

ERROR in node_modules/dslink/dist/dslink.node.d.ts(2,23): error TS2552: Cannot find name 'NodeJS'. Did you mean 'Node'?

如果需要更多信息,请告诉我。

【问题讨论】:

  • 如果你关注the source file where the error happens中的cmets,使用的版本是Node v6。您使用的是什么版本的 Node?​​span>
  • @PaulRey 正在使用节点 v6.12.3
  • 假设您在 Angular(客户端)中使用它 - 您不应该使用浏览器版本的 dslink (/dist/dslink.browser.js) 吗?
  • @lwallent 我应该如何以及在哪里指定这个?
  • @humblebee 这取决于您的构建/部署基础架构。您或许应该用更多细节更新您的问题。

标签: node.js angular typescript


【解决方案1】:

你有没有试过给定@NodeError的选项

【讨论】:

  • 我已经通过这个链接。不确定这是否是一个修复,因为我的浏览器控制台会抛出此错误:set location' called on an object that does not implement interface Window.
猜你喜欢
  • 2016-05-23
  • 2016-11-05
  • 1970-01-01
  • 2016-01-24
  • 2017-08-14
  • 2018-12-10
  • 2016-12-04
  • 2017-09-22
相关资源
最近更新 更多