我有以下项目的文件夹结构(这是一个开源bootstrap theme):
在package.json中我有以下命令:
"watch": "nodemon -e scss -x \"npm run build\"",
当我运行 npm run watch 时,它会删除dist文件夹。 这背后的原因是什么。删除dist文件夹后,css无法正常工作。如何解决这个问题呢? 为什么npm运行watch删除dist目录?
更新
从here安装grunt watch并在本地和全局安装grunt之后,现在我在终端中输出了这个输出:
PS C:\PROJECTS\Bootsrap\bootstrap-magic> grunt watch
>> Local Npm module "grunt-contrib-clean" not found. Is it installed?
>> Local Npm module "grunt-contrib-concat" not found. Is it installed?
>> Local Npm module "grunt-contrib-connect" not found. Is it installed?
>> Local Npm module "grunt-contrib-copy" not found. Is it installed?
>> Local Npm module "grunt-contrib-jshint" not found. Is it installed?
>> Local Npm module "grunt-contrib-qunit" not found. Is it installed?
>> Local Npm module "grunt-contrib-uglify" not found. Is it installed?
>> Local Npm module "grunt-html-validation" not found. Is it installed?
>> Local Npm module "grunt-jekyll" not found. Is it installed?
>> Local Npm module "grunt-contrib-less" not found. Is it installed?
Running "watch" task
Waiting...
答案 0 :(得分:1)
查看属于您所指的包的scripts
中的package.json
节点:
"scripts": {
"prod": "npm run build && ./node_modules/.bin/serve ./dist --single",
"dev": "./node_modules/serve/bin/serve.js",
"clean": "rimraf dist",
"watch": "nodemon -e scss -x \"npm run build\"",
"build": "npm run clean && NODE_ENV=production webpack"
}
watch
脚本运行build
,运行clean
,使用dist
删除rimraf
文件夹。