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 use within an Angular 8 project.

See original GitHub issue

I’m trying to use within my Angular 8 project but I get the next errors:

ERROR in ./node_modules/minio/dist/main/object-uploader.js
Module not found: Error: Can't resolve 'crypto' in 'D:\ng-minio\node_modules\minio\dist\main'
ERROR in ./node_modules/minio/dist/main/transformers.js
Module not found: Error: Can't resolve 'crypto' in 'D:\ng-minio\node_modules\minio\dist\main'
ERROR in ./node_modules/minio/dist/main/signing.js
Module not found: Error: Can't resolve 'crypto' in 'D:\ng-minio\node_modules\minio\dist\main'
ERROR in ./node_modules/minio/dist/main/minio.js
Module not found: Error: Can't resolve 'crypto' in 'D:\ng-minio\node_modules\minio\dist\main'
ERROR in ./node_modules/minio/dist/main/minio.js
Module not found: Error: Can't resolve 'fs' in 'D:\ng-minio\node_modules\minio\dist\main'
ERROR in ./node_modules/mkdirp/index.js
Module not found: Error: Can't resolve 'fs' in 'D:\ng-minio\node_modules\mkdirp'
ERROR in ./node_modules/minio/dist/main/minio.js
Module not found: Error: Can't resolve 'http' in 'D:\ng-minio\node_modules\minio\dist\main'
ERROR in ./node_modules/minio/dist/main/minio.js
Module not found: Error: Can't resolve 'https' in 'D:\ng-minio\node_modules\minio\dist\main'
ERROR in ./node_modules/mime-types/index.js
Module not found: Error: Can't resolve 'path' in 'D:\ng-minio\node_modules\mime-types'
ERROR in ./node_modules/minio/dist/main/minio.js
Module not found: Error: Can't resolve 'path' in 'D:\ng-minio\node_modules\minio\dist\main'
ERROR in ./node_modules/mkdirp/index.js
Module not found: Error: Can't resolve 'path' in 'D:\ng-minio\node_modules\mkdirp'
ERROR in ./node_modules/json-stream/lib/json-stream.js
Module not found: Error: Can't resolve 'stream' in 'D:\ng-minio\node_modules\json-stream\lib'
ERROR in ./node_modules/minio/dist/main/object-uploader.js
Module not found: Error: Can't resolve 'stream' in 'D:\ng-minio\node_modules\minio\dist\main'
ERROR in ./node_modules/minio/dist/main/helpers.js
Module not found: Error: Can't resolve 'stream' in 'D:\ng-minio\node_modules\minio\dist\main'
ERROR in ./node_modules/minio/dist/main/minio.js
Module not found: Error: Can't resolve 'stream' in 'D:\ng-minio\node_modules\minio\dist\main'
ERROR in ./node_modules/xml/lib/xml.js
Module not found: Error: Can't resolve 'stream' in 'D:\ng-minio\node_modules\xml\lib'
ERROR in ./node_modules/xml2js/lib/parser.js
Module not found: Error: Can't resolve 'timers' in 'D:\ng-minio\node_modules\xml2js\lib'

How can I do to add to my Angular project as a dependency and use it?

My package.json is composed by:

{
  "name": "ng-minio",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "core-js": "^2.5.4",
    "minio": "^7.0.12",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.13.0",
    "@angular/cli": "~7.3.3",
    "@angular/compiler-cli": "~7.2.0",
    "@angular/language-service": "~7.2.0",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/minio": "^7.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.2.2"
  }
}

Then I use in my app.component.ts as follow:

import { Component, OnInit } from '@angular/core';
import * as minio from 'minio';
import { environment } from '../environments/environment';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})
export class AppComponent implements OnInit {
  title = 'ng-minio';
  public minioClient;

  ngOnInit(): void {
    this.minioClient = new minio.Client({
      endPoint: 'play.min.io',
      port: 9000,
      useSSL: true,
      accessKey: 'Q3AM3UQ867SPQQA43P2F',
      secretKey: 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG'
    });
  }

  constructor() {

  }
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
loremapscommented, Apr 25, 2020

@bingiu minio-js seems to work fine with react. Please have a look here:

https://codesandbox.io/s/react-minio-js-example-9xtgo

3reactions
harshavardhanacommented, Jan 8, 2020

@mindfocus most definitely that is what we have always told - browser is only advisory support it is not part of the plan to support browser mode fully.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Handling with Angular 8 - Tips and Best Practices - Rollbar
One traditional way of handling errors in Angular is to provide an ErrorHandler class. This class can be extended to create your own...
Read more >
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 >
JS errors are not being logged in Angular 8 project - Browser
We tried to implement New Relic Browser in Angular 8 project but JS errors are not being logged. Other than JS errors we...
Read more >
My angular project failed to load showing error related content ...
The file was already existing on my directory. But when open from localhost/favicon.
Read more >
Angular compiler options
When you use the Angular CLI command ng new --strict , it is set to true in the created project's configuration. strictTemplates link....
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