Skip to content

v5.2.0: require doesn't work in REPL #4208

Description

@shinnn

Environment

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.11.1
BuildVersion:   15B42

$ node --version
v5.2.0

$ npm --version
3.3.12

$ pwd
/Users/shinnn/test

$ npm ls underscore
test@ /Users/shinnn/test
└── underscore@1.8.3

Problem

When I try to require locally installed "underscore" module, Node throws the following error.

$ node --version
v5.2.0
$ node
> require('underscore')
Error: Cannot find module 'underscore'
    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:1
    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)

With Node v5.1.1 it works fine.

$ node --version
v5.1.1
$ node
> require('underscore')
{ [Function]
  _: [Circular],
  VERSION: '1.8.3',
  [...] }

Also, when I directly specify the script path instead of the simple package name underscore, it can load the module as expected.

$ node --version
v5.2.0
$ node
> require('./node_modules/underscore/underscore.js')
{ [Function]
  _: [Circular],
  VERSION: '1.8.3',
  [...] }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.moduleIssues and PRs related to the module subsystem.replIssues and PRs related to the REPL subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions