shelljs / shx

Portable Shell Commands for Node
MIT License
1.72k stars 44 forks source link

Doesn't seem to work for "prepack" lifecycle script #168

Closed Venryx closed 4 years ago

Venryx commented 4 years ago

I added shx as a dev-dependency for my fork of an npm module here: https://github.com/Venryx/mst-decorators

However, even with it in the dev-dependencies, when I run npm install Venryx/mst-decorators in another project, I get this error:

PS C:\Root\Apps\@V\CDL\Client> npm install Venryx/mst-decorators

> mst-decorators@2.1.1 prepack C:\Users\Stephen\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-4f5c52b7
> yarn clean && yarn cjs && yarn esm

yarn run v1.19.1
$ shx rm -rf cjs esm
'shx' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
npm ERR! code ENOPACKAGEJSON
npm ERR! package.json Non-registry package missing package.json: github:Venryx/mst-decorators.
npm ERR! package.json npm can't find a package.json file in your current directory.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Stephen\AppData\Roaming\npm-cache\_logs\2019-11-17T08_34_21_636Z-debug.log

The problem seems to be that the dev-dependencies are only installed after running npm install in the mst-decorators folder -- not merely when my mst-decorators fork is being installed through the npm "install from github repo" function.

Any solution to this?

wmertens commented 4 years ago

npm install doesn't install the package's dev deps. Furthermore, prepack should only run before builing a tarball, so not as part of the install (https://docs.npmjs.com/misc/scripts).

So it's weird that it tries to run prepack without the dev dependencies.

nfischer commented 4 years ago

I'm not familiar with prepack, but if this is an npm script you expect dependent modules to run, or as part of running npm install, then you need to add shx to the regular dependencies rather than dev-dependencies.

I don't think there's anything for shx to do here, so I'm going to close this out. Please ping this if I've misunderstood.