khrome / ascii-art

A Node.js library for ansi codes, figlet fonts, ascii art and other ASCII graphics
MIT License
693 stars 288 forks source link

Module not found: Can't resolve 'fs' #25

Closed prinkpan closed 3 years ago

prinkpan commented 3 years ago

I did a yarn add ascii-art in my project, added window.art = require('ascii-art'); and tried to build using npm run build but it gives the following error:

Module not found: Can't resolve 'fs' in 'C:....\node_modules\ascii-art-image'

I am not so great with these tools so it can be something at my end that I am doing wrong.

khrome commented 3 years ago

I'll check this out today. There are some upcoming changes to go out, and f there's an issue I'll release a fix with that.

Thanks for the report!

khrome commented 3 years ago

For further detail can you give me your build command? It's very likely you're building for the web and need to exclude node specific modules.

prinkpan commented 3 years ago

You're right, I'm using this on my web app. Not sure what you mean by build command. I get the said error when I run npm run build. Sorry, I can't give more than this as I'm not so well versed with these tools. Thank you for looking into this.

khrome commented 3 years ago

npm run build executes whatever is in scripts.build in your package.json file, so there's no logic explicitly tied to that... it's wired individually for every module in your package.json.

You probably used a boilerplate generator that created this for you, but did not include commonly used configurations for building clientside versions of serverside modules.

likely you just need to tell it to not include fs in the browser... either in the babel config's resolve or in the config of whatever magic you're using on top of it.

khrome commented 3 years ago

Did this get sorted?

khrome commented 3 years ago

I'm going to call this good, reopen if there are issues.