node-gradle / gradle-node-plugin

Gradle plugin for integrating NodeJS in your build. :rocket:
Apache License 2.0
602 stars 118 forks source link

how to defined the npm install arguments? #210

Closed cstmgl closed 2 years ago

cstmgl commented 2 years ago

Hi all,

First I'm really not an expert in this plugin and npm itself but I have some questions.

I'm trying to get rid of a warning I get when installing my package.json but I'm failing to do so.

I get:

16:13:52  npm WARN install Usage of the `--dev` option is deprecated. Use `--also=dev` instead.

I tried to fix it like in the documentation with something like this.

npm_update {
  args = ['--production', '--loglevel', 'warn']
}

so I tried both:

npm_install {
  args = ['--also=dev']
}

or

npm_install {
  args = ['--also=dev']
}

But neither work so I'm just curious what I might be doing wrong. Or is the problem in my package.json and not a configuration of the plugin? my package json looks like this:

{
  "name": "smoke-test",
  "version": "1.0.0",
  "description": "Smoke tests for snowflake environment",
  "main": "index.js",
  "scripts": {
    "test": "node index.js"
  },
  "repository": {},
  "author": "Miguel Costa",
  "license": "UNLICENSED",
  "private": true,
  "dependencies": {
    "commander": "^8.3.0",
    "snowflake-sdk": "^1.6.6"
  }
}
deepy commented 2 years ago

When it comes to npm install the task you want to configure is pre-configured npmInstall which unfortunately isn't the same as the auto-generated npm_install that comes from the npm_foo task rule. (really sorry about the confusion here, it's a legacy thing and so far we don't have any easy to break the backwards compatibility for it but it's recommended to not use the rules)

Not sure where the --dev is coming from though, it doesn't exist in our codebase as far as I can tell

rainmore commented 2 years ago

Because of the issue Running with sudo or as root from node-sass, we apply --unsafe-perm as following

import com.github.gradle.node.npm.task.NpmInstallTask

…

tasks.named<NpmInstallTask>("npmInstall").configure {
    args.add("--unsafe-perm")
}

or

npmInstall {
    args = ['--unsafe-perm']
}

HTH

cstmgl commented 2 years ago

When it comes to npm install the task you want to configure is pre-configured npmInstall which unfortunately isn't the same as the auto-generated npm_install that comes from the npm_foo task rule. (really sorry about the confusion here, it's a legacy thing and so far we don't have any easy to break the backwards compatibility for it but it's recommended to not use the rules)

Not sure where the --dev is coming from though, it doesn't exist in our codebase as far as I can tell

I also download the source of the plugin and did not find any --dev so it for sure must be something on my side. Also the error only happens in jenkins not locally so most likely it's not a problem with the plugin. I will close this ticket. thank you for the feedback