Closed stevendesu closed 5 years ago
Sorry you're having cross-platform headaches :(
I'm not sure why you're having problems with package.json scripts (this is a supported use case)--at a glance, your package.json looks fine. On Windows, npm
modifies the %PATH%
to include node_modules/.bin/
, which should contain a script named shx.bat
(a small wrapper which invokes node, passing our declared "binary" file as an argument). Running shx
would invoke shx.bat
in cmd.exe
, and it seems you're not reaching this step. If you can identify which piece of the puzzle is missing on your system, I may be able to advise further.
I've never tried npx
, so I can't remark on your results there.
Sorry for the delayed response. It will be some time before I can test this for you. Tuesday morning my wife and I went to the hospital to give birth to our new baby. Until Saturday I won’t be back home.
Congrats! :tada: :balloon:
For some reason I'm not seeing a comment GitHub e-mailed me where someone reported they saw issues with shx rm
but not shx mkdir
. Perhaps they deleted the comment.
I'm working from home today so I sat down to look at this again (at the office I have a Mac, so I only really have issues when working from home on my Windows computer)
I took a peak in C:\Users\Steven Barnett\Source\xxx\node_modules\.bin
and there is no shx.bat
file there. The only files are webpack
and webpack.cmd
Now here's the thing: I deleted node_modules
and re-installed (via npm install
). This time the folder was full of files. Not just webpack
and shx
, but also acorn
, atob
, cake
, jsdoc
, node-sass
, etc.
My guess is that for some reason the NPM install process wasn't completing - perhaps node-sass was failing to compile or Webpack was attempting to copy a file into the .bin
directory that did not exist. I suspect that the "copy things to the .bin
directory" step is one of the last steps performed by NPM, and so everything else appeared to install correctly despite it error'ing out. I further suspect that a minor or patch update to one of my dependencies fixed the issues, because without making any changes to the package.json
file it's magically working now.
Ah, sounds like an npm bug in this case. I'll consider this resolved unless someone can identify shx-specific problems.
This is what resolved mine. I installed this shx package as dev dependency myself
yarn add -D shx
or npm i shx --dev
Hi all, I just tackled a similar issue on my environment.
My case is that I am using WSL console (Ubuntu terminal) in tandem with Windows PowerShell which turns out is not best practice. If you npm install
the packages with WSL terminal the *.bat files are not installed in .bin folder and obviously running any shx ...
commands in PowerShell (or anywhere outside WSL) would fail. So my fix is to stick to one terminal really.
Hope this would help someone. Cheers!
Further research may be necessary to determine the exact cause of the issue. If you have trouble reproducing, I'm willing to provide any additional information to help out.
My environment:
My package.json looks like so:
They two key lines here are that
shx
is installed (and can be found in thenode_modules
directory) and theclean
script, which utilizesshx
. On my Mac this worked perfectly. On Windows I'm getting the following error:If I install
shx
globally then I can use it just fine:However attempting to use
npx
to runshx
simply yields more errors:This and many others errors has made cross-platform development a real nightmare.