dsherret / ts-nameof

nameof in TypeScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't resolve 'fs'

john-larson opened this issue · comments

I am trying to use this library in a single page web application on the browser using Webpack. I installed the library via NPM. And I get the following error:

Can't resolve 'fs'

I do not know much about this module but a quick Google search seems to imply that it is a Node specific module. Is this library Node specific?

How are you using the library and which installation instructions did you follow? Make sure it’s a dev dependency... it’s a compile time transformation so it shouldn’t be used in any code at runtime.

I thought this was a run-time library. So, after making this configuration in Webpack.config, how should I use it in TypeScript without importing? Should I declare it as any in some part of my code?

Install @types/ts-nameof as well:

npm install ts-nameof @types/ts-nameof --save-dev

(Step 2: https://github.com/dsherret/ts-nameof/tree/master/packages/ts-nameof#setup)

Then you'll just be able to use nameof(something)

I'll have to add something more clear to the main readme.md file.

Thanks for the prompt help 👍