package.json scripts that work with npm and yarn?

前端 未结 2 1983
天涯浪人
天涯浪人 2021-02-13 18:38

I am using npm as a build tool and so in my package.json, and some of my scripts depend on other scripts:

{
  \"test\": \"npm run lint && mo         


        
2条回答
  •  执笔经年
    2021-02-13 19:37

    The $npm_execpath environment variable refers to the build tool, so just replace npm with the $npm_execpath:

    {
      "test": "$npm_execpath run lint && mocha"
    }
    

    Both npm test and yarn test will work, and will use the appropriate build tool.

提交回复
热议问题