Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant't resolve fs after updating to 13.0.3 version #304

Closed
spirosdi opened this issue Jan 13, 2020 · 3 comments
Closed

Cant't resolve fs after updating to 13.0.3 version #304

spirosdi opened this issue Jan 13, 2020 · 3 comments
Assignees
Labels

Comments

@spirosdi
Copy link

I am using file-type in an angular app. When running ng serve, I get the following:
ERROR in ./node_modules/strtok3/lib/FsPromise.js
Module not found: Error: Can't resolve 'fs' in /node_modules/strtok3/lib'
With v12 it works

@Borewit Borewit self-assigned this Jan 13, 2020
@Borewit
Copy link
Collaborator

Borewit commented Jan 13, 2020

And you did include (require) 'file-type/browser' instead of 'file-type' as described here @spirosdi?

@spirosdi
Copy link
Author

spirosdi commented Jan 14, 2020

ah right.. missing fs is now resolved. But I get a console error:

core.js:6014 ERROR Error: Uncaught (in promise): ReferenceError: process is not defined
ReferenceError: process is not defined
    at Object../node_modules/process-nextick-args/index.js (index.js:3)
    at __webpack_require__ (bootstrap:84)
    at Object../node_modules/readable-stream/lib/_stream_readable.js (_stream_readable.js:26)
    at __webpack_require__ (bootstrap:84)
    at Object../node_modules/readable-stream/readable-browser.js (readable-browser.js:1)
    at __webpack_require__ (bootstrap:84)
    at Object../node_modules/stream-browserify/index.js (index.js:28)
    at __webpack_require__ (bootstrap:84)
    at Object../node_modules/readable-web-to-node-stream/lib/index.js (index.js:3)
    at __webpack_require__ (bootstrap:84)
    at resolvePromise (zone-evergreen.js:797)
    at resolvePromise (zone-evergreen.js:754)
    at zone-evergreen.js:858
    at ZoneDelegate.invokeTask (zone-evergreen.js:391)
    at Object.onInvokeTask (core.js:39680)
    at ZoneDelegate.invokeTask (zone-evergreen.js:390)
    at Zone.runTask (zone-evergreen.js:168)
    at drainMicroTaskQueue (zone-evergreen.js:559)
defaultErrorLogger @ core.js:6014
handleError @ core.js:6066
next @ core.js:40558
schedulerFn @ core.js:35336
__tryOrUnsub @ Subscriber.js:183
next @ Subscriber.js:122
_next @ Subscriber.js:72
next @ Subscriber.js:49
next @ Subject.js:39
emit @ core.js:35298
(anonymous) @ core.js:39738
invoke @ zone-evergreen.js:359
run @ zone-evergreen.js:124
runOutsideAngular @ core.js:39572
onHandleError @ core.js:39735
handleError @ zone-evergreen.js:363
runGuarded @ zone-evergreen.js:137
api.microtaskDrainDone @ zone-evergreen.js:663
drainMicroTaskQueue @ zone-evergreen.js:566
Promise.then (async)
scheduleMicroTask @ zone-evergreen.js:542
scheduleTask @ zone-evergreen.js:381
onScheduleTask @ zone-evergreen.js:272
scheduleTask @ zone-evergreen.js:372
scheduleTask @ zone-evergreen.js:211
scheduleMicroTask @ zone-evergreen.js:231
scheduleResolveOrReject @ zone-evergreen.js:845
resolvePromise @ zone-evergreen.js:791
(anonymous) @ zone-evergreen.js:707
webpackJsonpCallback @ bootstrap:25
(anonymous) @ app-user-card-orders-card-orders-module.js:1

Just by including file-type/browser

@Borewit
Copy link
Collaborator

Borewit commented Jan 15, 2020

Some of the Node modules need to be polyfilled to make file-type work in the browser.

Install process:

npm i process

In polyfill.ts add:

import * as process from 'process';
(window as any).process = process;

You may need to add buffer as well:

npm i buffer

In polyfill.ts add:

import * as _buffer from 'buffer';
(window as any).Buffer = _buffer.Buffer;

Example: audio-tag-analyzer/blob/master/src/polyfills.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants