Skip to content

invoking ng from $(npm bin) throws: Error: Cannot find module '../package.json' #3257

@dastrobu

Description

@dastrobu

Please provide us with the following information:

OS

macOS Sierra

Versions.

angular-cli: 1.0.0-beta.20-4
node: 7.1.0
os: darwin x64

Repro steps.

install angular-cli as local dependency and call

$(npm bin)/ng --version

or any other parameter. Or alternatively call directly

./node_modules/.bin/ng --version

it always gives:

module.js:474
    throw err;
    ^

Error: Cannot find module '../package.json'
    at Function.Module._resolveFilename (module.js:472:15)
    at Function.Module._load (module.js:420:25)
    at Module.require (module.js:500:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> ([...]/node_modules/.bin/ng:8:21)
    at Module._compile (module.js:573:32)
    at Object.Module._extensions..js (module.js:582:10)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)

which cannot work, obviously, since there is no package.json.

The workaround is to call ng directly via

./node_modules/angular-cli/bin/ng --version

which works.

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