How do I add a custom script to my package.json file that runs a javascript file?

前端 未结 6 866
生来不讨喜
生来不讨喜 2020-11-29 17:01

I want to be able to execute the command script1 in a project directory that will run node script1.js.

script1.js is a file in

6条回答
  •  执念已碎
    2020-11-29 17:17

    Suppose I have this line of scripts in my "package.json"

    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "export_advertisements": "node export.js advertisements",
        "export_homedata": "node export.js homedata",
        "export_customdata": "node export.js customdata",
        "export_rooms": "node export.js rooms"
      },
    

    Now to run the script "export_advertisements", I will simply go to the terminal and type

    npm run export_advertisements
    

    You are most welcome

提交回复
热议问题