Node library requires lib unavailable for a web use

#1

Hi,

@Matt_Bramlage @Joe_Trollo I am using the official Node library for my Angular apps. When upgrading to latest Angular, I can’t build anymore.

ERROR in ./node_modules/readline/readline.js
Module not found: Error: Can't resolve 'fs' in '[...]node_modules/readline'
ERROR in ./node_modules/asana/lib/dispatcher.js
Module not found: Error: Can't resolve 'os' in '[...]node_modules/asana/lib'
ERROR in ./node_modules/asana/lib/util/buffered_readable.js
Module not found: Error: Can't resolve 'stream' in '[...]node_modules/asana/lib/util'

The issue seems to be that the library requires things (fs, os, stream) that don’t make sense in a web context. The solution I find online don’t work :frowning: any recommandation?

Thanks

0 Likes

#2

same issue…

0 Likes

#3

Same issue on my end. I end up linking directly to the min.js version of the library.

0 Likes

#4

Hello everyone,

For now, let’s go with Baadier_Sydow’s solution, and use the min.js version. You can change your import like this

// import {Client} from 'asana' 
import {Client} from 'asana/dist/asana-min.js'

or in tsconfig.json, add the change to paths

"compilerOptions": {
    "paths": {
        "asana": [ "node_modules/asana/dist/asana-min.js" ],
    }
}

I’m working towards a better solution for this, but keeping optional server functionality available within the library is getting more difficult due to recent webpack changes, and I’ve been unable to land on a great solution.

Best,
Ross

0 Likes

#5

My current solution is to manually change the content of node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js and replace node: false with node: { fs: "empty" }. But, oh my god, that is a dirty solution :pray: :angel:

0 Likes