Skip to content

resolve.sync doesn't respect NODE_PATH #39

Closed
@shlevy

Description

@shlevy

There is an inconsistency in how resolve.sync and require.resolve resolve paths:

$ NODE_PATH=/opt/grunt-0.4.2/lib/node_modules node
> require.resolve('grunt')
'/opt/grunt-0.4.2/lib/node_modules/grunt/lib/grunt.js'
> require('resolve').sync('grunt')
Error: Cannot find module 'grunt' from '.'
    at Function.module.exports [as sync] (/home/shlevy/test/node_modules/resolve/lib/sync.js:32:11)
    at repl:1:21
    at REPLServer.self.eval (repl.js:110:21)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.EventEmitter.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)
    at ReadStream.onkeypress (readline.js:99:10)
    at ReadStream.EventEmitter.emit (events.js:98:17)
>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions