question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when launching through angular

See original GitHub issue

Hi,

I’m using isomorphic-git in browser through an Angular 7 project. I successfully installed the project with npm install --save isomorphic-git but when launching my project with ng serve I encouter the following error :

ERROR in node_modules/isomorphic-git/src/index.d.ts(13,11): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.
node_modules/isomorphic-git/src/index.d.ts(115,13): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.node_modules/isomorphic-git/src/index.d.ts(561,11): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

@types/node is already installed and I tried updating it does not solve my problem.

The error is thrown when I import isomorphic-git in my components : import { clone } from 'isomorphic-git'

Is it a known problem and do you know if the library is compatible with angular projects ?

Regards,

Romain.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

5reactions
wmhiltoncommented, Oct 20, 2019

Status update:

We’re much closer to working out-of-the-box with Angular 7! (Edit: the same steps apply for Angular 8.) Which is also means were closer to achieving #698.

I was able to get our demo app running locally with only the following modifications:

package.json

...
  "dependencies": {
...
    "buffer": "^5.2.1",
    "path-browserify": "^1.0.0"
  },
...

polyfills.ts

...
(window as any).global = window;
(window as any).process = {};
import { Buffer } from 'buffer';
(window as any).Buffer = Buffer;

tsconfig.json

...
    "lib": [
      "esnext.asynciterable",
...
    ]
...

src/tsconfig.app.json

...
  "compilerOptions": {
...
    "types": ["node"],
    "paths": {
      "path": ["node_modules/path-browserify"]
    }
  }
...
1reaction
MikeJerredcommented, Apr 20, 2022

Only these changes are required with Angular 13:

package.json

"dependencies": {
  "buffer": "^6.0.3"
},
...

polyfills.ts

import { Buffer } from 'buffer';
(window as any).Buffer = Buffer;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Identify and Fix Build and Deployment Errors in Your Angular ...
In this guide, you will learn how to spot some of the most common build and deployment errors and how to resolve them...
Read more >
Errors List - Angular
Errors Listlink · NG0100: Expression Changed After Checked · NG01003: Wrong Async Validator Return Type · NG01203: Missing value accessor · NG0200: Circular ......
Read more >
Error Launching on the Angular/Electron app - Stack Overflow
I have created an angular 10 project using the angular-CLI. ... Installed Electron locally. but when run my code, it shows have some...
Read more >
Error Handling with Angular 8 - Tips and Best Practices - Rollbar
Handling errors properly is essential in building a robust application in Angular. Error handlers provide an opportunity to present friendly ...
Read more >
Angular Error Handling Best Practices - Medium
Expecting the Unexpected — Best practices for Error handling in Angular ... Statuses starting with five (5xx) are server errors. The most typical...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found