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

ReferenceError: __dirname is not defined #56

Closed
EvgenyOrekhov opened this issue Aug 24, 2020 · 7 comments · Fixed by #57
Closed

ReferenceError: __dirname is not defined #56

EvgenyOrekhov opened this issue Aug 24, 2020 · 7 comments · Fixed by #57

Comments

@EvgenyOrekhov
Copy link

v1.4.0 worked fine.

v2.1.1 throws the following error:

vendor.js:137754 Uncaught (in promise) ReferenceError: __dirname is not defined
    at push../node_modules/http-status-codes/build/index.js.module.exports.527 (vendor.js:137754)
    at Object../node_modules/http-status-codes/build/index.js (vendor.js:137787)
    at __webpack_require__ (vendor.js:105790)

I'm using it like this (example reduced to minimal case):

import { StatusCodes } from "http-status-codes";

console.log(StatusCodes.UNAUTHORIZED);

Culprit: build/index.js:38

/******/ 	__webpack_require__.ab = __dirname + "/";

http-status-codes: 2.1.1
Environment: Ember 3.18
Node: 12.18.3
Browser: Chrome 84

@tonivj5
Copy link

tonivj5 commented Aug 24, 2020

I'm using this module at browser too. Could you add a browser compatible bundle?

image

Thanks for the module! Simple and clean 👍

@prettymuchbryce
Copy link
Owner

Sorry about that. This should be resolved now in v2.1.2

@elkinjosetm
Copy link

elkinjosetm commented Aug 27, 2020

I'm having the same error but on React Native and on v2.1.2:

Simulator Screen Shot - iPhone 11 - 2020-08-27 at 11 37 17

And it's exactly the same line /******/ __webpack_require__.ab = __dirname + "/";

If I remove it, the app runs correctly as expected

@prettymuchbryce
Copy link
Owner

@elkinjosetm Which version of http-status-codes are you using? Can you confirm you're using v2.1.2?

The __webpack_require__ line should only appear in the common.js module. I would expect that React Native would use the ES module.

@elkinjosetm
Copy link

@prettymuchbryce sorry I edited the comment later to mention the version I'm using. Yes, I'm using v2.1.2, I would expect the same.

@elkinjosetm
Copy link

Any update on this? @prettymuchbryce

@prettymuchbryce
Copy link
Owner

@elkinjosetm Can you try this beta version and let me know if it solves your issue?

http-status-codes@2.1.3-beta.0

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

Successfully merging a pull request may close this issue.

4 participants