microsoft / VoTT

Visual Object Tagging Tool: An electron app for building end to end Object Detection Models from Images and Videos.
MIT License
4.27k stars 833 forks source link

ReferenceError: require is not defined #1010

Open rayguang opened 3 years ago

rayguang commented 3 years ago

Describe the bug I am adding a new cloud storage support by using min.io (https://docs.min.io/docs/javascript-client-api-reference.html). After running npm start, no particular error. When I go to http://localhost, received the following error:

`ReferenceError: require is not defined Module../node_modules/minio/node_modules/async/dist/async.mjs http://localhost/static/js/0.chunk.js:215453:30 __webpack_require__ src/app/webpack/bootstrap:782 779 | }; 780 | 781 | // Execute the module function

782 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); | ^ 783 | 784 | // Flag the module as loaded 785 | module.l = true; View compiled fn src/app/webpack/bootstrap:150 147 | ); 148 | hotCurrentParents = []; 149 | } 150 | return webpack_require(request); | ^ 151 | }; 152 | var ObjectFactory = function ObjectFactory(name) { 153 | return { View compiled ▶ 2 stack frames were collapsed. webpack_require src/app/webpack/bootstrap:782 779 | }; 780 | 781 | // Execute the module function 782 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); | ^ 783 | 784 | // Flag the module as loaded 785 | module.l = true; View compiled fn src/app/webpack/bootstrap:150 147 | ); 148 | hotCurrentParents = []; 149 | } 150 | return webpack_require(request); | ^ 151 | }; 152 | var ObjectFactory = function ObjectFactory(name) { 153 | return { View compiled ▶ 2 stack frames were collapsed. webpack_require src/app/webpack/bootstrap:782 779 | }; 780 | 781 | // Execute the module function 782 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); | ^ 783 | 784 | // Flag the module as loaded 785 | module.l = true;`

To Reproduce I have created several files and made most changes in minioStorage.ts by replacing the functions similar to azureStorage.ts with minio API

Expected behavior A clear and concise description of what you expected to happen. A sample of the code listed below:

`import { IStorageProvider } from "./storageProviderFactory"; import { IAsset, AssetType, StorageType } from "../../models/applicationState"; import { AssetService } from "../../services/assetService"; import * as minio from "minio"; import { Bounce } from "react-toastify";

//var minio = require("minio");

const minioClient = new minio.Client({ endPoint: "localhost", port: 9000, useSSL: false, accessKey: "xxxx", secretKey: "xxxxxxx" });

/**

export class MinioStorage implements IStorageProvider { /**

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

kobotschick commented 3 years ago

Have you checked this version of minio storage provider ? https://github.com/rayguang/ray_vott/blob/master/src/providers/storage/minioStorage.ts

rayguang commented 3 years ago

The above link is authored by me :-)

I finally got it working by using the browserify. I am not a Javascript programmer but did some research to figure this out. I will publish what I have done once all code are finalized.

kobotschick commented 3 years ago

Ok, fine. I am interested!