npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

how to use parent folder's .bin in npm scripts?

npm version: 6.10.2

node version: v8.11.4

OS: windows 10

I has a project structure like this:

Now the root app has the eslint as devDependencies.

I don’t want to install eslint in global or in every sub app, so the sub app like common payroll want to use the root level eslint cmd to excute eslint check.

In the common app’s npm scripts, I write next command:

"eslint": "./../node_modules/.bin/eslint src --ext .tsx,ts --resolve-plugins-relative-to ../"
“eslint”: “…/node_modules/.bin/eslint src --ext .tsx,ts --resolve-plugins-relative-to …/”

It not work.

The error info:

> common@1.0.0 eslint F:\Playground\LeyserV9InWebPlayGround\common
> ./../node_modules/.bin/eslint src --ext .tsx,ts --resolve-plugins-relative-to ../

'.' is not recognized as an internal or external command,
operable program or batch file.

I know it’s because the PATH only include the path $absolute_path/root_app/common/node_modules/.bin, but not include the path $absolute_path/root_app/node_modules/.bin.

But I want know how to resolve this problems?

Best Regards.

The shell that is running when you call your script does not understand the relative path: ./../node_modules/.bin/eslint

By default, on Unix-like systems it is the /bin/sh command, on Windows it is the cmd.exe .