Skip to content

[BUG] npm -C ./dir exec cmd fails #2078

@acomagu

Description

@acomagu

Current Behavior:

npm -C ./dir exec foo fails with ENOENT, even if ./dir contains package.json.

Expected Behavior:

npm -C ./dir exec foo runs foo command in ./dir directory.

Steps To Reproduce:

$ cd $(mktemp -d)
$ mkdir dir
$ cd dir
$ npm i cowsay
$ npm exec cowsay a             # <- Success
$ cd ..
$ npm -C ./dir ls               # <- Success
$ npm -C ./dir exec cowsay a    # <- ERROR
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /tmp/tmp.PSJSuTrxHx/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/tmp/tmp.PSJSuTrxHx/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/tmp.vynlwg6kj4/.npm/_logs/2020-10-29T07_45_41_525Z-debug.log

Environment:

  • OS: Manjaro Linux(Linux acm-manjaro 4.19.147-1-MANJARO SMP Wed Sep 23 18:00:56 UTC 2020 x86_64 GNU/Linux)
  • Node: 15.0.1
  • npm: 7.0.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingRelease 7.xwork is associated with a specific npm 7 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions