replace icon indicating copy to clipboard operation
replace copied to clipboard

`replace` a keyword in windows cmd.exe

Open eteeselink opened this issue 12 years ago • 7 comments

Hi! Lovely util. Without all the drama I would've never come across it.

Now, I tried using it on Windows, and got really weird behaviour, until I realized that there's actually a cmd.exe command called "replace". I solved it by copying .../npm/replace.cmd to .../npm/replacejs.cmd. Maybe it would be good to include that alias by default? Or, if npm allows, by default on Windows systems?

eteeselink avatar Jan 24 '13 06:01 eteeselink

Ooh, that's not good. Thanks for reporting this. I'll look into it.

harthur avatar Jan 25 '13 03:01 harthur

replace is also a keyword used by maria-db

cod3beat avatar Jun 19 '13 03:06 cod3beat

But can you run npm scripts from mariadb? i mean, maybe I'm missing something, but how is that a problem?

eteeselink avatar Jun 19 '13 06:06 eteeselink

What i meant was maria-db also has a command line prompt named replace. So it clashes with this replace

cod3beat avatar Jun 19 '13 12:06 cod3beat

I was just about to make your package a dependency on our project, as it looks like it'll be the perfect fit, but then I tried typing "replace" on my command line and found that I, too, have such an executable in my path already (it comes with MAMP for OS X). I wonder if you'd best rename your utility to something a little less likely to cause name clashes? "replace" is certainly a common word.

farmerpaul avatar Jan 08 '14 22:01 farmerpaul

I have had this problem too. There are several ways to get around it.

  1. make an alias in your shell to whatever you want
  2. directly execute the node_module ./node_modules/.bin/replace
  3. fork it, change the executable name npm install username/replace --save

I'm sure there are plenty more.

wlaurance avatar Jan 08 '14 23:01 wlaurance

I'm not using it globally, but the command works perfectly in Windows cmd.exe so long as it's either called as node_modules\.bin\replace or from a script in package.json. One Windows-specific note which might trip up the unix-fluent (me): Arguments must be enclosed in double-quotes. Single-quotes do something different in the default Window CLI.

C:\Users\joe\Desktop\replacer> node_modules\.bin\replace "foo" "bar" foobar.txt

👍

joemaller avatar Oct 21 '16 16:10 joemaller