Skip to content

[5.2.0] REPL - module.paths empty #4240

@SpainTrain

Description

@SpainTrain

In 5.1.1 and previous, requireing modules in the REPL worked. However, it appears that module.paths is empty in the REPL when using 5.2 and thus require fails. System environment and explanatory output below:

OS: Ubuntu 15.10 4.2.0-19-generic #23-Ubuntu SMP Wed Nov 11 11:39:30 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

$ echo $NODE_PATH
/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript:/home/spainhower/npm/lib/node_modules

spainhower at spainbuntu in ~/repos/linter-pylint on master
$ which node
/home/spainhower/npm/n/bin/node

spainhower at spainbuntu in ~/repos/linter-pylint on master
$ node -v
v5.1.1

spainhower at spainbuntu in ~/repos/linter-pylint on master
$ node
> module.paths
[ '/home/spainhower/repos/linter-pylint/repl/node_modules',
  '/home/spainhower/repos/linter-pylint/node_modules',
  '/home/spainhower/repos/node_modules',
  '/home/spainhower/node_modules',
  '/home/node_modules',
  '/node_modules' ]
> ld = require('lodash')
{ [Function: lodash]
  support: {},
  templateSettings: 
   { escape: /<%-([\s\S]+?)%>/g,
     evaluate: /<%([\s\S]+?)%>/g,
     interpolate: /<%=([\s\S]+?)%>/g,
     variable: '',
     imports: { _: [Circular] } },
  after: [Function: after],
  ary: [Function: ary],
  <...TRUNCATED FOR BREVITY...>
  include: [Function: includes],
  inject: [Function],
  sample: [Function: sample],
  VERSION: '3.10.1',
  _: [Circular] }
> 
(To exit, press ^C again or type .exit)
> 

spainhower at spainbuntu in ~/repos/linter-pylint on master
$ n 5.2

spainhower at spainbuntu in ~/repos/linter-pylint on master
 1 $ which node
/home/spainhower/npm/n/bin/node

spainhower at spainbuntu in ~/repos/linter-pylint on master
$ node -v
v5.2.0

spainhower at spainbuntu in ~/repos/linter-pylint on master
$ node
> module.paths
undefined
> ld = require('lodash')
Error: Cannot find module 'lodash'
    at Function.Module._resolveFilename (module.js:327:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:355:17)
    at require (internal/module.js:13:17)
    at repl:1:6
    at REPLServer.defaultEval (repl.js:252:27)
    at bound (domain.js:281:14)
    at REPLServer.runBound [as eval] (domain.js:294:12)
    at REPLServer.<anonymous> (repl.js:417:12)
    at emitOne (events.js:83:20)
> module.paths
[]
>

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateIssues and PRs that are duplicates of other issues or PRs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions