当我运行npm运行时,它会从项目的根目录中删除dist文件夹

时间:2018-05-25 10:07:42

标签: c# npm

我有以下项目的文件夹结构(这是一个开源bootstrap theme):

enter image description here

在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...

1 个答案:

答案 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文件夹。