question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReferenceError: __dirname is not defined

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
prettymuchbrycecommented, Aug 24, 2020

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

0reactions
prettymuchbrycecommented, Sep 4, 2020

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

http-status-codes@2.1.3-beta.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is __dirname not defined in node REPL?
__dirname is only defined in scripts. It's not available in REPL. try make a script a.js console.log(__dirname);. and run it: node a.js.
Read more >
How to fix "__dirname is not defined in ES module scope"
I stumbled on this error while I used __dirname inside a ES module. In an ES module, you cannot use __dirname . Using...
Read more >
__dirname is not defined · Issue #2907 · nodejs/help · ...
I wrote a simple program: console.log('Hello world'); console.log(__dirname); Error: Hello world file:///C:/prj/akb48teamsh/html/t.js:2 ...
Read more >
Fix "__dirname is not defined in ES module scope" in ...
One error you'll likely run into is "Uncaught ReferenceError: __dirname is not defined in ES module scope". This error is exactly what it ......
Read more >
Fix "__dirname is not defined in ES module scope" in JS
To solve the "__dirname is not defined in ES module scope" error, import and use the dirname() method from the path module. The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found