How to specify path(like npm --prefix) in npx?
Asked Answered
C

2

31

This is my folder structure:

project/
└── test_cases
    └── package.json

The working dir is project/. I want to run eslint (an npm package) from working dir. I dont wish to cd into test_case. I install the same package from work dir by
sudo npm install --prefix test_cases/.

Theres no such option for npx. npx eslint from working dir downloads from the internet. I want to run them from the test_cases dir. Help!

Catchy answered 18/3, 2020 at 12:26 Comment(1)
github.com/npm/npx/issues/74Hoyle
M
5

I managed to work around this problem by using

npm exec --prefix test_cases eslint
Mesothelium answered 21/10, 2022 at 13:17 Comment(0)
H
-3

As mentioned in github issue in npm@7 and above you can specify --workspace option for this:

npx -w test_cases eslint

https://github.com/npm/npx/issues/74#issuecomment-676092733

Henig answered 21/1, 2022 at 12:12 Comment(1)
Gave error, Could not read package.json: Error: ENOENT: no such file or directoryGaiser

© 2022 - 2024 — McMap. All rights reserved.