Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Creating Your Own Arbitrary Tasks

Bozhong Tao
Bozhong Tao
18,365 Points

'cp' is not recognized as an internal or external command when running copy-files task

I've encountered this strange issue where the PowerShell will throw an error prompt below:

'cp' is not recognized as an internal or external command

I did some research online and replace the "cp" with "copy", not working. Also I tried to type "cp src/.html build/" and "src/.css build/" separately in the PowerShell and it worked fine @@, I can get newly created html and css fine in the build folder just fine.

Only when I concatenate the two cp/copy together and put them into a single task, I will hit the wall(npm run build/npm run copy-files).

My package.json is as below:

{
  "name": "dice_simulator_2015",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "test": "mocha",
    "uglify": "uglifyjs src/models/* src/frontend.js -m -c -o build/app.js",
    "copy-files": "copy src/*.html build/ & copy src/*.css build/",
    "build": "npm run copy-files && npm run uglify"
  },
  "author": "Bo",
  "license": "MIT",
  "devDependencies": {
    "mocha": "^2.2.5",
    "uglify-js": "^2.4.23"
  }
}

Any ideas? Thanks for the tips :)

2 Answers

Taylor Johnson
Taylor Johnson
14,220 Points

I got this to work:

"copy-files": "@powershell copy src/*.html build/; copy src/*.css build/"

You just have to specify that it's a powershell command with the @powershell and you can separate commands with a ; instead of an &.

kieran venison
kieran venison
9,093 Points

I presume this is because of us running this example in windows and not linux is that correct?

cp is a unix command, so it doesn't work on Windows. You can use something like MINGW64 or other unix bash emulator, in that way you can use unix command.