NPM clean modules

前端 未结 8 599
时光取名叫无心
时光取名叫无心 2020-12-24 00:14

Is there a way to get npm to unbuild all the modules under node_modules? Something like npm rebuild that removes all build artifacts but doesn\'t rebuild them?

相关标签:
8条回答
  • 2020-12-24 00:31

    I added this to my package.json:

    "build": "npm build",
    "clean": "rm -rf node_modules", 
    "reinstall": "npm run clean && npm install", 
    "rebuild": "npm run clean && npm install && npm run build",
    

    Seems to work well.

    0 讨论(0)
  • 2020-12-24 00:42

    There is actually special command for this job

    npm ci
    

    It will delete node_modules directory and will install packages with respect your package-lock.json file

    More info: https://docs.npmjs.com/cli/ci.html

    0 讨论(0)
提交回复
热议问题