prettymuchbryce/http-status-codes

ReferenceError: __dirname is not defined

Closed this issue · 7 comments

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

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

image

Thanks for the module! Simple and clean 👍

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

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

@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.

@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.

Any update on this? @prettymuchbryce

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

http-status-codes@2.1.3-beta.0