Closed
Description
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',
[...] }