From 54d4079457ff915172ae513d7612fb3730a01ea8 Mon Sep 17 00:00:00 2001 From: ZJ van de Weg Date: Sun, 17 Sep 2023 08:22:15 +0200 Subject: [PATCH] npm: Remove production flag on npm invocation When installing packages the `--production` flag used to be added to the arguments that `npm` received. As npm wants developers to use the `--omit=dev` flag instead it warned users on STDERR. Standard error was captured by Node-RED and output to the logs as being an error. This caught users off-guard and they expected something to have gone wrong. With this change the `--omit=dev` is used instead, to remove the warning. This change works for NPM of version 8 and beyond[1], included in Node.JS 16. This change will not work on NPM version 6[2] which is included in Node.JS 14[3]. [1]: https://docs.npmjs.com/cli/v8/commands/npm-install#omit [2]: https://docs.npmjs.com/cli/v6/commands/npm-install [3]: https://nodejs.org/en/download/releases#looking-for-latest-release-of-a-version-branch --- packages/node_modules/@node-red/registry/lib/externalModules.js | 2 +- packages/node_modules/@node-red/registry/lib/installer.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/@node-red/registry/lib/externalModules.js b/packages/node_modules/@node-red/registry/lib/externalModules.js index b76f748a4..476f3dfbf 100644 --- a/packages/node_modules/@node-red/registry/lib/externalModules.js +++ b/packages/node_modules/@node-red/registry/lib/externalModules.js @@ -263,7 +263,7 @@ async function installModule(moduleDetails) { "module": moduleDetails.module, "version": moduleDetails.version, "dir": installDir, - "args": ["--production","--engine-strict"] + "args": ["--omit=dev","--engine-strict"] } return hooks.trigger("preInstall", triggerPayload).then((result) => { // preInstall passed diff --git a/packages/node_modules/@node-red/registry/lib/installer.js b/packages/node_modules/@node-red/registry/lib/installer.js index 95022fbb1..aeb22be3d 100644 --- a/packages/node_modules/@node-red/registry/lib/installer.js +++ b/packages/node_modules/@node-red/registry/lib/installer.js @@ -215,7 +215,7 @@ async function installModule(module,version,url) { "dir": installDir, "isExisting": isExisting, "isUpgrade": isUpgrade, - "args": ['--no-audit','--no-update-notifier','--no-fund','--save','--save-prefix=~','--production','--engine-strict'] + "args": ['--no-audit','--no-update-notifier','--no-fund','--save','--save-prefix=~','--omit=dev','--engine-strict'] } return hooks.trigger("preInstall", triggerPayload).then((result) => {