Experience-Monks / Experience-Monks/devtool

Relative `require` paths do not work in the Console

Open
#84 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
3.7k
Forks
147
PR merge metrics
No merged PRs in 30d

Description

Assuming I'm in the parent directory of the module I'm attempting to `require`...

``` sh
devtool
```

Then type in the Console:

``` js
require('./my-module') // throws error: Cannot find module './my-module'
```

Since no `__dirname` exists in the Console, the relative `require` cannot be resolved by Electron.

---

The workaround:

``` js
require(process.cwd() + '/my-module')
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.