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

Error: Cannot find module, despite NODE_PATH being set #135

Open
janstrohbeck opened this issue Dec 4, 2017 · 0 comments
Open

Error: Cannot find module, despite NODE_PATH being set #135

janstrohbeck opened this issue Dec 4, 2017 · 0 comments

Comments

@janstrohbeck
Copy link

Description

I use Typescript with a basePath setting, so that I can require my files from an absolute base path:

import navigation from 'redux/interfaces/navigation'

This gets transpiled to:

const _navigation = require('redux/interfaces/navigator')

The redux folder is in ./src/internal, so I have to set NODE_PATH accordingly.

I want to use iron-node to debug my mocha unit test, which I can execute like this:

NODE_PATH=./src/internal node node_modules/mocha/bin/_mocha --opts mocha.opts 'tests/**/*.spec.ts' 'tests/**/*.spec.tsx'

This works, but if I replace node with iron-node, it cannot find the files in ./src/internal (see error log below)

Steps to Reproduce

I reproduced the issue with the following 2-file setup:

  1. Create file src/internal/redux/interfaces/navigation.js:
 module.exports = {
    a: true
}
  1. Create file test/test.js:
const _navigation = require('redux/interfaces/navigation')
console.log(_navigation.a)
  1. Execute in shell (runs without errors): NODE_PATH=./src/internal node test/test.js
  2. Execute in shell (fails with module not found): NODE_PATH=./src/internal iron-node test/test.js

Expected behavior: [What you expect to happen]

iron-node should run without errors and find the required file.

Actual behavior: [What actually happens]

iron-node does not find the required file.

Reproduces how often: [What percentage of the time does it reproduce?]

Always.

Screenshot(s): [Screenshot(s) or animated gifs of the error situtaion]

Error log(s): From devTools console or shell terminal

app.js:197 ironNode boot
/usr/lib/node_modules/iron-node/app/require-custom-wrap.js:32 Object {v8: Object, app: Object, workSpaceDirectory: function}
app.js:268 ModedModule {}
app.js:58   Error: Cannot find module 'redux/interfaces/navigation'
  
  - reset-search-paths.js:35 Function.Module._resolveFilename
    [lib]/[iron-node]/[electron]/dist/resources/electron.asar/common/reset-searc    h-paths.js:35:12
  
  - module.js:20 require
    internal/module.js:20:19
  
  - test.js:1 Object.<anonymous>
    /tmp/test-project/test/test.js:1:176
  
  - test.js:3 Object.<anonymous>
    /tmp/test-project/test/test.js:3:3
  

error @ app.js:58
emitOne @ events.js:96
emit @ events.js:191
window.onerror @ /usr/lib/node_modules/iron-node/node_modules/electron/dist/resources/electron.asar/renderer/init.js:135
app.js:59 Details Error: Cannot find module 'redux/interfaces/navigation'
    at Module._resolveFilename (module.js:470)
    at Function.Module._resolveFilename (/usr/lib/node_modules/iron-node/node_modules/electron/dist/resources/electron.asar/common/reset-sea…:35)
    at Function.Module._load (module.js:418)
    at Module.require (module.js:498)
    at require (internal/module.js:20)
    at Object.<anonymous> (/tmp/test-project/test/test.js:1)
    at Object.<anonymous> (/tmp/test-project/test/test.js:3)
    at Module._compile (module.js:571)
    at Object.Module._extensions..js (module.js:580)
    at Module.load (module.js:488)
error @ app.js:59
emitOne @ events.js:96
emit @ events.js:191
window.onerror @ /usr/lib/node_modules/iron-node/node_modules/electron/dist/resources/electron.asar/renderer/init.js:135

Version(s)

versions

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

No branches or pull requests

1 participant