2

我们在 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 "package-name",我会收到以下错误

> 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 installpreinstallpackage.json,当我提供时,它会一次又一次地无限执行同一行npm install <package-name>

4

0 回答 0