` engineering strict :パッケージ内でTRUE `を返します.JSONは問題です


パッケージを発行したり、github経由でインストールを許可している場合.
npm i custom-package         # From NPM registry
npm i ${REPO}/custom-package   # From GitHub repo main branch
その後、パッケージの問題が発生しますが、誤って設定のためにインストールすることはできませんpackage.json
{
  "engines": {
    "node": "14",
    "npm": "please-use-yarn",
    "yarn": "1",
    "pnpm": "please-use-yarn"
  },
  "engineStrict": true
}

解決策


echo 'engine-strict=true' >> .npmrc

問題NPMチーム無視


そうですengineStrict: truepackage.json ) 第1位では動作しません.糸のみPNPM.
でもecho 'engine-strict=true' >> .npmrc 作品

問題糸チーム無視


無効にする糸の実行に警告がありますpackage.json , 含むengines .

提案:有効なエンジンとして 菅8072



iliazeus
掲示される
ビジュアルスタジオコードrequires を含む拡張"vscode" プロパティ"engines" フィールドpackage.json . しかしyarn それは有効なエンジンであることを知りません.
yarn add v1.22.4
[1/5] Validating package.json...
warning [email protected]: The engine "vscode" appears to be invalid.
View on GitHub
だから、最初の場所で警告しない場所は、公式の糸チームによって異なりますか?It is hard-coded by Yarn. 他の誰かがパッケージを公開するためにPNPMを使ったときも起こります.

PNPMに係わる問題


私も、これが同様に修正するのが難しいかもしれないと思います.それは次のメジャーリリース、または取得に行く可能性がありますwontfix .

非デフォルトノードを持つNVMRC。JSのバージョンは動作しません 宗角3016



patarapolw
掲示される

PNPM版:


5.5.5

問題を再現するコード

nvm install 12
nvm install 14
nvm alias default 12
echo '14' > .nvmrc
nvm use
echo 'engine-strict=true' >> .npmrc
# add `engineStrict: true` in `package.json` also works

Then, add engines field in package.json.

{
  "engines": {
    "node": "14"
  }
}

予想される動作:

No errors, install successfully.

実際の動作

❯ pnpm i
 ERROR  Your Node version is incompatible with "/home/patarapolw/projects/aloud-comments".

Expected version: 14
Got: v12.19.0

This is happening because the package's manifest has an engines.node field specified.
To fix this issue, install the required Node version.

もう一つの模写方法

  • 取り外しengine-strict=true
  • 追加node --version スクリプトセクション
  • Found '/home/patarapolw/projects/aloud-comments/.nvmrc' with version <14>
    Now using node v14.15.1 (npm v6.14.8)
    ❯ pnpm node:version
    
    > [email protected] node:version /home/patarapolw/projects/aloud-comments
    > node --version
    
    v12.19.0
    

    もう一つの模写方法

  • pnpm i @stencil/core
  • Found '/home/patarapolw/projects/aloud-comments/.nvmrc' with version <14>
    Now using node v14.15.1 (npm v6.14.8)
    ❯ pnpm serve
    > [email protected] serve /home/patarapolw/projects/aloud-comments
    > stencil build --dev --watch --serve
    Your current version of Node is v12.19.0, however Stencil's recommendation is v14.5.0 or greater. Note that future versions of Stencil will eventually remove support for non-LTS Node versions and an Active LTS version is recommended (https://nodejs.org/en/about/releases/).
    
    もちろん、ステンシルチームはあなたのバグだと言いましたない.

    追加情報:

  • Windows、MacOS、Linuxとは?WSL 2の上のUbuntu 20.04
  • ❯ node -v
    v14.15.1
    ❯ cat /proc/version
    Linux version 4.19.128-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Tue Jun 23 12:58:10 UTC 2020
    ❯ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 20.04.1 LTS
    Release:        20.04
    Codename:       focal
    
    View on GitHub

    ブロッキングスクリプトのプリインストールは十分ではありません

  • pnpm run それでも間違ったノードを拾う.JSバージョン.
  • npm publish , yarn publish , pnpm publish すべて別の仕事.engine-strict この場合はブロックすることができます.
  • 私は好むyarn publish 最も.