在不同环境下管理纱线安装的最佳做法

问题描述 投票:0回答:1

在MacOS和Linux上,我的点文件使用相同的package.json。直到最近当其中一个软件包停止在Linux上安装时,这才成为问题。 (失败的原因是该软件包期望安装MacOS应用程序Alfred)。在我的Linux环境中找不到该文件时,安装失败。

管理此类事物的最佳方法是什么?我应该有两个不同的package.json文件吗?一种用于一般用途,一种用于Mac专用软件包?

作为参考,我目前拥有的依赖项是:

  "devDependencies": {
    "acorn": "^7.1.0"
  },
  "dependencies": {
    "alfred-fkill": "^0.4.1",
    "bash-language-server": "^1.6.1",
    "eslint": "^6.6.0",
    "fkill-cli": "^5.2.0",
    "jsonlint": "^1.6.3",
    "prettier": "^1.19.1"
  }

我在Linux下收到的错误是:

$ yarn upgrade
yarn upgrade v1.19.0
[1/4] Resolving packages...
warning alfred-fkill > fkill > taskkill > execa > [email protected]: cross-spawn no longer requires a build toolchain, use it instead
warning bash-language-server > turndown > jsdom > [email protected]: use String.prototype.padStart()
warning jsonlint > [email protected]: Package no longer supported. Contact [email protected] for more info.
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Rebuilding all packages...
error /home/oalders/dot-files/node_modules/alfred-fkill: Command failed.
Exit code: 1
Command: alfy-init
Arguments:
Directory: /home/oalders/dot-files/node_modules/alfred-fkill
Output:
{ Error: Command failed: alfred-link
Error: Alfred preferences not found at location /home/oalders/Library/Application Support/Alfred/prefs.json
    at module.exports (/home/oalders/dot-files/node_modules/resolve-alfred-prefs/index.js:44:9)
    at makeError (/home/oalders/dot-files/node_modules/alfy/node_modules/execa/index.js:174:9)
    at Promise.all.then.arr (/home/oalders/dot-files/node_modules/alfy/node_modules/execa/index.js:278:16)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  code: 1,
  stdout: '',
  stderr:
   'Error: Alfred preferences not found at location /home/oalders/Library/Application Support/Alfred/prefs.json\n    at module.exports (/home/oalders/dot-files/node_modules/resolve-alfred-prefs/index.js:4
4:9)\n',
  failed: true,
  signal: null,
  cmd: 'alfred-link',
  timedOut: false,
  killed: false }
info Visit https://yarnpkg.com/en/docs/cli/upgrade for documentation about this command.
node.js yarnpkg package.json dotfiles alfred
1个回答
0
投票

我对此的解决方法是,我决定滥用devDependencies。我已将alfred-fkill(仅MacOS节点模块)声明为开发依赖项。然后在Linux上运行yarn install --production=true。这将忽略开发人员部门,并且我不再会失败。在Mac上,我将运行yarn install,它将像以前一样安装所有内容。这可行,但是很奇怪。

我还有:

  "devDependencies": {
    "alfred-fkill": "^0.4.1"
  },
  "dependencies": {
    "acorn": "^7.1.0",
    "bash-language-server": "^1.6.1",
    "eslint": "^6.6.0",
    "fkill-cli": "^5.2.0",
    "jsonlint": "^1.6.3",
    "prettier": "^1.19.1"
  }
© www.soinside.com 2019 - 2024. All rights reserved.