在postinstall生命周期中运行Grunt任务 - NPM

时间:2017-06-22 05:13:21

标签: npm gruntjs npm-install npm-scripts

我们在GIT存储库中有一个jQuery UI组件列表。用户可以根据需要包含整个包。如果用户希望将特定组件单独包含到他们的项目中,则用户可以设置环境变量"组件"提到他们想要包含的组件。根据它的值,我想用提供的值执行一个grunt任务。我的包的package.json如下。我想这样做是因为我不想为每个组件维护一个单独的GIT存储库,因为维护非常困难。

{
  "name": "<package-name>",
  "version": "3.0.24",
  "description": "<value>",
  "main": "<value>",
  "scripts": {
    "postinstall": "cross-var grunt --component=$npm_config_component",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "<value>"
  },
  "keywords": [
    "jquery-plugin",
    "ecosystem:jquery"
  ],
  "author": "<value>",
  "license": "ISC",
  "devDependencies": {
    "grunt": "^1.0.1",
    "grunt-cli": "^1.2.0",
    "grunt-contrib-concat": "^1.0.1",
    "grunt-contrib-copy": "^1.0.0",
    "grunt-contrib-cssmin": "^2.2.0",
    "grunt-contrib-sass": "^1.0.0",
    "grunt-contrib-uglify": "^3.0.1"
  }
}

但问题出在发布后如果我提供 npm install&#34; package-name&#34; ,我收到以下错误

> cross-var grunt --component=$npm_config_component

>> Local Npm module "grunt-contrib-concat" not found. Is it installed?
>> Local Npm module "grunt-contrib-uglify" not found. Is it installed?
>> Local Npm module "grunt-contrib-sass" not found. Is it installed?
>> Local Npm module "grunt-contrib-cssmin" not found. Is it installed?
>> Local Npm module "grunt-contrib-copy" not found. Is it installed?
Warning: Task "concat" not found. Use --force to continue.

Aborted due to warnings.

我尝试将devDependencies移至dependencies并尝试重新安装该软件包。但似乎没什么用。我还尝试将npm install放在my package.json preinstall中,当我提供npm install <package-name>

0 个答案:

没有答案