Can't run executable script when installing local packages


(Sqal) #1

In order to demonstrate my problem, i’ve created a minimal reproduction respository which you can clone from https://github.com/sqal/playground1 and here’s my issue

Steps to reproduce

  • Clone repo
  • npm install
  • Navigate to directory apps/app1 and run npm run serve

What is expected?

I expect executable script from the package @project/service located in packages/service to run correctly

What is actually happening?

I get this error instead:

's' is not recognized as an internal or external command,

My understanding is that the script does not work currently not because there’s no executable script s in the apps/app1/node_modules/.bin, but why npm did not create this file during npm install? is it because @project/service is listed the root package.json and is hoisted in the root node_modules (which is what I want btw)? I also tried to run this script using a relative path to the root node_modules like this:

"serve": "../../node_modules/.bin/s"

But this time, I got another error

> ../../node_modules/.bin/s

'..' is not recognized as an internal or external command,

which is very weird, because path is correct and the script is definitely in root node_modules/.bin folder. I would appreciate if someone could give more details on why I can’t execute this serve command and what is the right way to fix it. Thanks.


(Lars Willighagen) #2

If you’re using Windows, the path to the executable probably isn’t recognised as such due to Windows having a different path syntax (instead of / they use \). So instead of seeing a path it sees .. as a command because / probably isn’t allowed in command names.


(John Gee) #3

The install at the parent level does not cause an install to run in the apps folders. When you run npm from ./apps/app1 it is in a folder with a package.json but the directory is bare, so s is not known.

(app1 has been installed to ./node_modules/@project/app1, but that is also different than running npm install in app1.)

This hopefully shows the issue, without guessing what you were intending to happen:

$ npm install
$ cd apps/app1
$ npm run --silent serve
sh: s: command not found
$ npm install
$ npm run --silent serve
Service /Users/john/Documents/Sandpits/playground1/apps/app1 []

(system) #4

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.