如何在 Windows 10 上运行 rm 命令? [英] How to run rm command on windows 10?

查看:471
本文介绍了如何在 Windows 10 上运行 rm 命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

"build": "rm -rf ./build && mkdir ./build && ./node_modules/.bin/babel -d ./build ./src"

这是 package.json 中的命令,它给了我一个错误说:

This is the command in package.json and it gives me an error saying:

rm is not recognized as internal or external command.
Invalid switch /build

推荐答案

该脚本是为 UNIX shell 编写的,在 Windows 上不起作用.以跨平台方式执行此操作的正确方法是使用 rimraf &mkdirp.

That script was written for the UNIX shell, which does not work on windows. The correct way to do this in a cross-platform way is to use rimraf & mkdirp.

此外,./node_modules/.bin/babel 部分可以缩短为简单的 babel (./node_modules/.bin/babel> 不适用于 Windows IIRC).

Also, the ./node_modules/.bin/babel portion could be shortened to simply babel (./node_modules/.bin/babel doesn't work on windows IIRC).

写得好,脚本应该是:

"build": "rimraf ./build && mkdirp ./build && babel -d ./build ./src"

要使此脚本工作,您必须安装 rimrafmkdirp.您可以通过运行:

For this script to work, you will have to install rimraf and mkdirp. You can do this by running:

npm install --save-dev rimraf mkdirp

--save-dev 标志会将 rimrafmkdirp 添加到您的 package.jsondevDependencies 部分,以便它们将在以后的 npm install 中自动安装.

The --save-dev flag will add rimraf and mkdirp to your package.json's devDependencies section so that they will automatically be installed with future npm installs.

这篇关于如何在 Windows 10 上运行 rm 命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆