Error ts2503 cannot find namespace nodejs

I can't seem to get azure-devops-node-api working. I tried to create a minimal example: Start new.. npm init npm install --save-dev typescript npm install --save azure-devops-node-api create in...

I can’t seem to get azure-devops-node-api working. I tried to create a minimal example:

Start new..

  1. npm init
  2. npm install —save-dev typescript
  3. npm install —save azure-devops-node-api
  4. create index.ts like so:
    import * as azdev from "azure-devops-node-api";
    
    // your collection url
    let orgUrl = "https://dev.azure.com/yourorgname";
    
    // ideally from config
    let token: string = "cbdeb34vzyuk5l4gxc4qfczn3lko3avfkfqyb47etahq6axpcqha"; 
    
    let authHandler = azdev.getPersonalAccessTokenHandler(token); 
    let connection = new azdev.WebApi(orgUrl, authHandler);   
    

running tsc yields:

> test1@1.0.0 build D:_devtest1
> tsc

node_modules/azure-devops-node-api/BuildApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/BuildApi.d.ts(9,93): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(11,113): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(13,128): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(34,158): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(40,113): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(43,64): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(44,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(57,89): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(80,146): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(81,120): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(115,93): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(132,113): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(151,128): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(362,158): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(411,113): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(435,64): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(445,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(558,89): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(730,146): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(738,120): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/FileContainerApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/FileContainerApi.d.ts(7,31): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/FileContainerApi.d.ts(8,125): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/FileContainerApi.d.ts(18,125): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/FileContainerApi.d.ts(19,31): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/FileContainerApi.d.ts(20,75): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/GitApi.d.ts(11,144): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(12,104): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(13,140): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(37,354): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(39,351): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(40,350): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(43,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(45,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(47,112): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(126,139): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(168,144): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(177,104): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(188,140): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(414,354): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(444,351): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(460,350): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(489,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(507,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(524,112): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(1250,139): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/interfaces/common/VsoBaseInterfaces.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/interfaces/common/VsoBaseInterfaces.d.ts(2,23): error TS2307: Cannot find module ‘http’.
node_modules/azure-devops-node-api/interfaces/common/VsoBaseInterfaces.d.ts(3,22): error TS2307: Cannot find module ‘url’.
node_modules/azure-devops-node-api/interfaces/common/VsoBaseInterfaces.d.ts(55,58): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/interfaces/common/VsoBaseInterfaces.d.ts(56,62): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/interfaces/common/VsoBaseInterfaces.d.ts(57,51): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/interfaces/common/VsoBaseInterfaces.d.ts(58,63): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(13,183): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(14,206): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(24,100): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(49,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(50,58): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(51,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(52,178): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(53,168): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(64,105): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(70,93): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(154,183): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(166,206): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(246,100): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(443,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(450,58): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(460,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(473,178): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(485,168): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(589,105): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(634,93): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/TaskAgentApi.d.ts(6,84): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApi.d.ts(25,114): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApi.d.ts(47,84): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(70,76): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(81,51): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(99,108): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(107,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(130,91): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(137,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(554,76): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(613,51): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(711,108): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(778,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(946,91): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(996,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/TaskApi.d.ts(8,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskApi.d.ts(10,159): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskApi.d.ts(13,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskApi.d.ts(47,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskApi.d.ts(67,159): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskApi.d.ts(93,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/TestApi.d.ts(13,125): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(15,121): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(16,153): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(18,149): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(20,96): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(22,92): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(179,125): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(196,121): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(206,153): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(225,149): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(241,96): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(256,92): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(16,102): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(18,265): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(20,262): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(21,261): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(129,102): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(155,265): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(178,262): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(191,261): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WikiApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/WikiApi.d.ts(7,224): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WikiApi.d.ts(8,223): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WikiApi.d.ts(29,224): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WikiApi.d.ts(40,223): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(13,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(14,104): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(15,100): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(53,75): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(54,76): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(127,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(136,104): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(145,100): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(447,75): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(455,76): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/HttpClient.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/typed-rest-client/HttpClient.d.ts(2,22): error TS2307: Cannot find module ‘url’.
node_modules/typed-rest-client/HttpClient.d.ts(3,23): error TS2307: Cannot find module ‘http’.
node_modules/typed-rest-client/HttpClient.d.ts(70,58): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/HttpClient.d.ts(76,62): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/HttpClient.d.ts(86,55): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/HttpClient.d.ts(93,67): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/Interfaces.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/typed-rest-client/Interfaces.d.ts(2,23): error TS2307: Cannot find module ‘http’.
node_modules/typed-rest-client/Interfaces.d.ts(3,22): error TS2307: Cannot find module ‘url’.
node_modules/typed-rest-client/Interfaces.d.ts(18,58): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/Interfaces.d.ts(19,62): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/Interfaces.d.ts(20,51): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/Interfaces.d.ts(21,63): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/RestClient.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/typed-rest-client/RestClient.d.ts(71,63): error TS2503: Cannot find namespace ‘NodeJS’.

The old Issue#58 says:

Installing typings should resolve this. […]

However, the project comes with it’s own typings.. So I am unsure which typings to install.

Содержание

  1. Русские Блоги
  2. Node.js Setup:This may indicate a problem with this package. The error code is 2503.
  3. Метод 1.
  4. Метод 2.
  5. Интеллектуальная рекомендация
  6. Реализация оценки приложения iOS
  7. JS функциональное программирование (е)
  8. PWN_JarvisOJ_Level1
  9. Установка и развертывание Kubernetes
  10. На стороне многопроцессорного сервера — (2) *
  11. error TS2503: Cannot find namespace ‘NodeJS’ — again #289
  12. Comments

Русские Блоги

Node.js Setup:This may indicate a problem with this package. The error code is 2503.

Недавно из-за причин стажировки (в частности, потому что бакалавры введены в эксплуатацию, чтобы есть память и ЦП, моя низкая оборудованная скорость RMBP немного медленная), чтобы мигрировать на разработку Windows 10.

Самым большим преимуществом является 4 ГГц CPU, 32G память, а стоимость — это определенная стоимость адаптации. Когда я установил Node.js, я соответствовал следующему вопросу:

Советы по ошибкам не очевидны, но общие причины недостаточно.

Метод 1.

Обходной путь — это установщик Windows для запуска Node.js под привилегиями PowerShell из администратора.

Вышеуказанный путь определяется в соответствии с вашим индигром, а затем его должно быть успешно установлено:

Метод 2.

Когда я появился выше, я использовал низкую версию Windows 10, которая очень вероятно, что пиратство. Конечно, есть и другие проблемы. Другие вопросы не так легко решить. Позже я использовал последнее зеркало Microsoft Windows 10. Я столкнулся с всеми вопросами, я никогда не появлялся снова.

Интеллектуальная рекомендация

Реализация оценки приложения iOS

Есть два способа получить оценку приложения: перейти в App Store для оценки и оценка в приложении. 1. Перейдите в App Store, чтобы оценить ps: appid можно запросить в iTunes Connect 2. Встроенная оцен.

JS функциональное программирование (е)

Давайте рассмотрим простой пример, чтобы проиллюстрировать, как используется Reduce. Первый параметр Reduce — это то, что мы принимаем массив arrayOfNums, а второй параметр — функцию. Эта функция прин.

PWN_JarvisOJ_Level1

Nc первый Затем мы смотрим на декомпиляцию ida Перед «Hello, World! N» есть уязвимая_функция, проверьте эту функцию после ввода Видно, что только что появившийся странный адрес является пе.

Установка и развертывание Kubernetes

На самом деле, я опубликовал статью в этом разделе давным -давно, но она не достаточно подробно, и уровень не является ясным. Когда я развернулся сегодня, я увидел его достаточно (хотя это было успешн.

На стороне многопроцессорного сервера — (2) *

Обработка сигнала Родительский процесс часто очень занят, поэтому вы не можете просто вызвать функцию waitpid, чтобы дождаться завершения дочернего процесса. Затем обсудите решение. Обратитесь .

Источник

error TS2503: Cannot find namespace ‘NodeJS’ — again #289

I can’t seem to get azure-devops-node-api working. I tried to create a minimal example:

  1. npm init
  2. npm install —save-dev typescript
  3. npm install —save azure-devops-node-api
  4. create index.ts like so:

running tsc yields:

node_modules/azure-devops-node-api/BuildApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/BuildApi.d.ts(9,93): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(11,113): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(13,128): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(34,158): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(40,113): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(43,64): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(44,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(57,89): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(80,146): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(81,120): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(115,93): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(132,113): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(151,128): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(362,158): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(411,113): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(435,64): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(445,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(558,89): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(730,146): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/BuildApi.d.ts(738,120): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/FileContainerApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/FileContainerApi.d.ts(7,31): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/FileContainerApi.d.ts(8,125): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/FileContainerApi.d.ts(18,125): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/FileContainerApi.d.ts(19,31): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/FileContainerApi.d.ts(20,75): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/GitApi.d.ts(11,144): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(12,104): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(13,140): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(37,354): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(39,351): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(40,350): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(43,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(45,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(47,112): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(126,139): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(168,144): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(177,104): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(188,140): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(414,354): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(444,351): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(460,350): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(489,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(507,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(524,112): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/GitApi.d.ts(1250,139): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/interfaces/common/VsoBaseInterfaces.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/interfaces/common/VsoBaseInterfaces.d.ts(2,23): error TS2307: Cannot find module ‘http’.
node_modules/azure-devops-node-api/interfaces/common/VsoBaseInterfaces.d.ts(3,22): error TS2307: Cannot find module ‘url’.
node_modules/azure-devops-node-api/interfaces/common/VsoBaseInterfaces.d.ts(55,58): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/interfaces/common/VsoBaseInterfaces.d.ts(56,62): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/interfaces/common/VsoBaseInterfaces.d.ts(57,51): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/interfaces/common/VsoBaseInterfaces.d.ts(58,63): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(13,183): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(14,206): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(24,100): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(49,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(50,58): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(51,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(52,178): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(53,168): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(64,105): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(70,93): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(154,183): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(166,206): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(246,100): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(443,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(450,58): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(460,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(473,178): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(485,168): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(589,105): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/ReleaseApi.d.ts(634,93): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/TaskAgentApi.d.ts(6,84): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApi.d.ts(25,114): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApi.d.ts(47,84): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(70,76): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(81,51): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(99,108): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(107,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(130,91): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(137,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(554,76): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(613,51): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(711,108): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(778,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(946,91): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskAgentApiBase.d.ts(996,116): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/TaskApi.d.ts(8,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskApi.d.ts(10,159): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskApi.d.ts(13,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskApi.d.ts(47,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskApi.d.ts(67,159): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TaskApi.d.ts(93,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/TestApi.d.ts(13,125): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(15,121): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(16,153): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(18,149): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(20,96): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(22,92): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(179,125): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(196,121): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(206,153): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(225,149): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(241,96): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TestApi.d.ts(256,92): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(16,102): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(18,265): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(20,262): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(21,261): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(129,102): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(155,265): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(178,262): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/TfvcApi.d.ts(191,261): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WikiApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/WikiApi.d.ts(7,224): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WikiApi.d.ts(8,223): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WikiApi.d.ts(29,224): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WikiApi.d.ts(40,223): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(13,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(14,104): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(15,100): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(53,75): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(54,76): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(127,57): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(136,104): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(145,100): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(447,75): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/azure-devops-node-api/WorkItemTrackingApi.d.ts(455,76): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/HttpClient.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/typed-rest-client/HttpClient.d.ts(2,22): error TS2307: Cannot find module ‘url’.
node_modules/typed-rest-client/HttpClient.d.ts(3,23): error TS2307: Cannot find module ‘http’.
node_modules/typed-rest-client/HttpClient.d.ts(70,58): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/HttpClient.d.ts(76,62): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/HttpClient.d.ts(86,55): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/HttpClient.d.ts(93,67): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/Interfaces.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/typed-rest-client/Interfaces.d.ts(2,23): error TS2307: Cannot find module ‘http’.
node_modules/typed-rest-client/Interfaces.d.ts(3,22): error TS2307: Cannot find module ‘url’.
node_modules/typed-rest-client/Interfaces.d.ts(18,58): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/Interfaces.d.ts(19,62): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/Interfaces.d.ts(20,51): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/Interfaces.d.ts(21,63): error TS2503: Cannot find namespace ‘NodeJS’.
node_modules/typed-rest-client/RestClient.d.ts(1,23): error TS2688: Cannot find type definition file for ‘node’.
node_modules/typed-rest-client/RestClient.d.ts(71,63): error TS2503: Cannot find namespace ‘NodeJS’.

Installing typings should resolve this. [. ]

However, the project comes with it’s own typings.. So I am unsure which typings to install.

The text was updated successfully, but these errors were encountered:

Источник

Issue

I was try to export an excel file using ExcelJS

Here is my console in VS Code terminal :

ERROR in node_modules/exceljs/index.d.ts:1398:22 - error TS2307: Cannot find module 'stream'.

1398  read(stream: import('stream').Stream): Promise<Workbook>;
                          ~~~~~~~~
node_modules/exceljs/index.d.ts:1424:23 - error TS2307: Cannot find module 'stream'.

1424  write(stream: import('stream').Stream, options?: Partial<XlsxWriteOptions>): Promise<void>;
                           ~~~~~~~~
node_modules/exceljs/index.d.ts:1511:22 - error TS2307: Cannot find module 'stream'.

1511  read(stream: import('stream').Stream, options?: Partial<CsvReadOptions>): Promise<Worksheet>;
                          ~~~~~~~~
node_modules/exceljs/index.d.ts:1531:23 - error TS2307: Cannot find module 'stream'.

1531  write(stream: import('stream').Stream, options?: Partial<CsvWriteOptions>): Promise<void>;
                           ~~~~~~~~
node_modules/exceljs/index.d.ts:1828:19 - error TS2307: Cannot find module 'stream'.

1828            stream: import('stream').Stream;
                               ~~~~~~~~
node_modules/exceljs/index.d.ts:1872:34 - error TS2503: Cannot find namespace 'NodeJS'.

1872             dictionary: Buffer | NodeJS.TypedArray | DataView | ArrayBuffer; // deflate/inflate only, empty dictionary by default                                      ~~~~~~

here is app.component.html

<!DOCTYPE html>
<html lang="en">

<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> -->

  <!-- serial must : first jquery then popper then bootstrap -->
  <!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script> -->


</head>

<body>

    <div class="row">

      <div class="col-md-2">
        <button class="btn btn-secondary" (click)='downloadExcel()'>Download as Excel</button>
      </div>

    </div>

</body>

</html>

here is app.component.ts

import { Component } from '@angular/core';
import * as Excel from 'exceljs';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'resttest10';

  async downloadExcel() {

    const date = new Date().toISOString().slice(0, 10).split('-').reverse().join('/');
    console.log(date);
    const workbook = new Excel.Workbook();
    const worksheet = workbook.addWorksheet('My Sheet');

    worksheet.columns = [
      { header: 'Id', key: 'id', width: 10 },
      { header: 'Name', key: 'name', width: 32 },
      { header: 'D.O.B.', key: 'dob', width: 15, }
    ];

    worksheet.addRow({ id: 1, name: 'John Doe', dob: new Date(1970, 1, 1) });
    worksheet.addRow({ id: 2, name: 'Jane Doe', dob: new Date(1965, 1, 7) });

    // save under export.xlsx
    await workbook.xlsx.writeFile('export.xlsx');

    // load a copy of export.xlsx
    const newWorkbook = new Excel.Workbook();
    await newWorkbook.xlsx.readFile('export.xlsx');

    const newworksheet = newWorkbook.getWorksheet('My Sheet');
    newworksheet.columns = [
      { header: 'Id', key: 'id', width: 10 },
      { header: 'Name', key: 'name', width: 32 },
      { header: 'D.O.B.', key: 'dob', width: 15, }
    ];
    await newworksheet.addRow({ id: 3, name: 'New Guy', dob: new Date(2000, 1, 1) });

    await newWorkbook.xlsx.writeFile('export2.xlsx');

    console.log('File is written');
  }
}

I don’t get it why it is looking for stream module (and more funny thing — Cannot find namespace ‘NodeJS’ — I can run all other angular NodeJS projects without error)

Please point out why i can’t export excel.

Solution

You can’t write directly a file on client side. that method is mean to be used on backend side in nodejs. if your expectation is download this file on client side. your code should be like :-

import { Component } from "@angular/core";
import * as Excel from "exceljs";
@Component({
  selector: "my-app",
  templateUrl: "./app.component.html",
  styleUrls: ["./app.component.css"]
})
export class AppComponent {
  title = "resttest10";

  async downloadExcel() {
    const date = new Date()
      .toISOString()
      .slice(0, 10)
      .split("-")
      .reverse()
      .join("/");
    console.log(date);
    const workbook = new Excel.Workbook();
    const worksheet = workbook.addWorksheet("My Sheet");

    worksheet.columns = [
      { header: "Id", key: "id", width: 10 },
      { header: "Name", key: "name", width: 32 },
      { header: "D.O.B.", key: "dob", width: 15 }
    ];

    worksheet.addRow({ id: 1, name: "John Doe", dob: new Date(1970, 1, 1) });
    worksheet.addRow({ id: 2, name: "Jane Doe", dob: new Date(1965, 1, 7) });

    workbook.xlsx.writeBuffer().then((data: any) => {
      console.log("buffer");
      const blob = new Blob([data], {
        type:
          "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
      });
      let url = window.URL.createObjectURL(blob);
      let a = document.createElement("a");
      document.body.appendChild(a);
      a.setAttribute("style", "display: none");
      a.href = url;
      a.download = "export.xlsx";
      a.click();
      window.URL.revokeObjectURL(url);
      a.remove();
    });
  }
}

Answered By — Aakash Garg

Понравилась статья? Поделить с друзьями:
  • Error ts18002 the files list in config file tsconfig json is empty
  • Error ts1345 an expression of type void cannot be tested for truthiness
  • Error ts1192 module fs has no default export
  • Error ts1086 an accessor cannot be declared in an ambient context
  • Error ts1056 accessors are only available when targeting ecmascript 5 and higher