Preloader
Web development
  • Estimated reading time: 2 Minutes

Learn how to solve the NPM error 'cp' is not recognized as an internal or external command, operable program or batch file

Many developers use open source plugins and projects to speed up the development process of their projects. Sometimes, many of those projects were made in unix based platforms (not everybody uses windows my friend), so when you download a project for example made with Node.js and tools to build like NPM, you will find some problems when using it in a distinct platform from where it was originally made.

In this case, if you see the NPM error "cp" is not recognized as an internal or external command, the project was surely developed in Mac, Linux etc. For example, if you try to run the build command of the following script (package.json):

{
    /* Rest of your package.json file */
    "scripts": {
        "build": "babel-node -- node_modules/webpack/bin/webpack -p --config tools/webpack.config && cp demo\\assets\\js\\form-* dist\\",
    },
    /* Rest of your package.json file */
}

It will throw the exception in Windows as the cp command doesn't exist in Windows.

Solution 1

Fortunately, the problem is just a syntax incompatibility between Windows and Unix based systems, so changing manually the cp command with copy will fix the problem:

{
    /* Rest of your package.json file */
    "scripts": {
        "build": "babel-node -- node_modules/webpack/bin/webpack -p --config tools/webpack.config && copy demo\\assets\\js\\form-* dist\\",
    },
    /* Rest of your package.json file */
}

Now the previous command should work in Windows. The only problem is the maintainability of the project, as you will always need to change this when you are working in windows, however comes in handy if you are working only for you or you are not intending to commit any changes to the original repository of the project.

Solution 2

You can as well install Cygwin on Windows to provide support for the "cp" command. Cygwin is a large collection of GNU and Open Source tools which provide functionality similar to a Linux distribution on Windows. The most recent version of the Cygwin DLL till the date of publication of this article is 2.9.0. Install it by running setup-x86.exe (32-bit installation) or setup-x86_64.exe (64-bit installation). Use the setup program to perform a fresh install or to update an existing installation.

After installing Cygwin, closing the command prompt and restarting it will allow you to run the build command without a problem using the cp command of unix, so you wouldn't need to modify the package.json file manually.

Happy coding !

Share:
Carlos Delgado

Carlos Delgado

Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Related articles
The Convergence of AI, Cybersecurity & Modern Web Development | OST
16 Jun, 2026
  • Estimated reading time: 4 Minutes
WordPress vs Custom Website: Which is Better for Your Business?
23 Apr, 2026
  • Estimated reading time: 5 Minutes
Guidelines To Follow In Test Case Writing
4 Mar, 2026
  • Estimated reading time: 4 Minutes
How to Build a Secure Authentication System in a Web Application
27 Feb, 2026
  • Estimated reading time: 5 Minutes
Weekly trending
What Makes a Portable Power Station Worth the Investment?
17 Jun, 2026
  • Estimated reading time: 4 Minutes
Building a Modern Lead Generation Workflow With Public Social Data
17 Jun, 2026
  • Estimated reading time: 3 Minutes
Best Instant Crypto Exchange for Lazy Investors
17 Jun, 2026
  • Estimated reading time: 6 Minutes
Our Sponsors

Our blog is proudly supported by industry-leading sponsors.