Gradle couldn't execute npm command
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I'm trying to run a npm command inside of gradle task but I'm getting a strange error:
Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'npm'
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:65)
... 2 more
Caused by: java.io.IOException: Cannot run program "npm" (in directory "/Users/psilva/Documents/projects/registrolivre"): error=2, No such file or directory
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
... 4 more
Caused by: java.io.IOException: error=2, No such file or directory
And this is my task:
task npmInstall(type: Exec) {
commandLine "npm", "install"
}
Could someone help?
java intellij-idea gradle npm npm-install
add a comment |
I'm trying to run a npm command inside of gradle task but I'm getting a strange error:
Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'npm'
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:65)
... 2 more
Caused by: java.io.IOException: Cannot run program "npm" (in directory "/Users/psilva/Documents/projects/registrolivre"): error=2, No such file or directory
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
... 4 more
Caused by: java.io.IOException: error=2, No such file or directory
And this is my task:
task npmInstall(type: Exec) {
commandLine "npm", "install"
}
Could someone help?
java intellij-idea gradle npm npm-install
Does this directory exist? /Users/psilva/Documents/projects/registrolivre
– RaGe
Feb 22 '16 at 1:11
add a comment |
I'm trying to run a npm command inside of gradle task but I'm getting a strange error:
Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'npm'
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:65)
... 2 more
Caused by: java.io.IOException: Cannot run program "npm" (in directory "/Users/psilva/Documents/projects/registrolivre"): error=2, No such file or directory
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
... 4 more
Caused by: java.io.IOException: error=2, No such file or directory
And this is my task:
task npmInstall(type: Exec) {
commandLine "npm", "install"
}
Could someone help?
java intellij-idea gradle npm npm-install
I'm trying to run a npm command inside of gradle task but I'm getting a strange error:
Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'npm'
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:65)
... 2 more
Caused by: java.io.IOException: Cannot run program "npm" (in directory "/Users/psilva/Documents/projects/registrolivre"): error=2, No such file or directory
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
... 4 more
Caused by: java.io.IOException: error=2, No such file or directory
And this is my task:
task npmInstall(type: Exec) {
commandLine "npm", "install"
}
Could someone help?
java intellij-idea gradle npm npm-install
java intellij-idea gradle npm npm-install
asked Feb 21 '16 at 18:28
Pedro HenriquePedro Henrique
3071618
3071618
Does this directory exist? /Users/psilva/Documents/projects/registrolivre
– RaGe
Feb 22 '16 at 1:11
add a comment |
Does this directory exist? /Users/psilva/Documents/projects/registrolivre
– RaGe
Feb 22 '16 at 1:11
Does this directory exist? /Users/psilva/Documents/projects/registrolivre
– RaGe
Feb 22 '16 at 1:11
Does this directory exist? /Users/psilva/Documents/projects/registrolivre
– RaGe
Feb 22 '16 at 1:11
add a comment |
4 Answers
4
active
oldest
votes
This answer worked for me with a different npm-related task. The recommendation there is to use an executable and args rather than commandLine.
executable 'npm'
args ['install']
Depending on your directory structure, you may also need to add the workingDir property and set it to the directory where your package.json lives.
As an alternative, the Gradle Node Plugin is also really handy for managing the most common Node tasks in a Gradle build. I use this plugin as the basis for my Node tasks and then create other custom tasks as needed.
I had the same problem with IntelliJ and Gradle. The Gradle Node Plugin referred in this answer solved my integration problem and cleaned a bit npm related tasks too.
– iaarnio
Apr 21 '17 at 7:59
add a comment |
If you are on Windows try this:
task npmInstall(type: Exec) {
commandLine "npm.cmd", "install"
}
instead of this:
task npmInstall(type: Exec) {
commandLine "npm", "install"
}
This worked for me. I had to create.npmrc
file on the project root though to ignore thestrict-ssl
.
– Ashok M A
Oct 1 '18 at 12:57
add a comment |
If you are using Windows OS, you have to use 'npm.cmd' instead of 'npm'. Better to detect whether OS is windows or not and build your npm command. Please see the code snippet below,
import org.apache.tools.ant.taskdefs.condition.Os
task npmInstall(type: Exec) {
String npm = 'npm';
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
npm = 'npm.cmd'
}
workingDir 'src/main/webapp'
commandLine npm, 'install'
}
add a comment |
I used @ALDRIN P VINCENT answer to solve this issue. But if you need to pass command line arguments to npm script, you can do this:
Let's say following system properties are passed to gradle script
gradle test-Dsome1=dev -Dsome2=https://www.google.com
In your test script in build.gradle, you will do this:
task apifunctionaltest(type: Exec) {
String npm = 'npm';
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
npm = 'npm.cmd'
}
commandLine npm, 'run', 'test', '--', '--some1='+System.getProperty("some1"), '--some2='+System.getProperty("some2")
}
The main command starts with commandLine npm… This line equates to:
npm run test -- --some1=dev --some2=https://www.google.com
The test script in package.json also should have ‘npm install’ (it depends) command so node modules are installed before tests run. And if modules are already installed, node will not waste time and reinstall them. test script should be something like this:
"scripts": {
"test": "npm install && webpack"
}
And then you can pick those command line args thru process.argv[2]
and process.argv[3]
.
If you have a simple script like mine, then some1 and some2 will be in the 2nd and 3rd position of an array, respectively.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35540126%2fgradle-couldnt-execute-npm-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
This answer worked for me with a different npm-related task. The recommendation there is to use an executable and args rather than commandLine.
executable 'npm'
args ['install']
Depending on your directory structure, you may also need to add the workingDir property and set it to the directory where your package.json lives.
As an alternative, the Gradle Node Plugin is also really handy for managing the most common Node tasks in a Gradle build. I use this plugin as the basis for my Node tasks and then create other custom tasks as needed.
I had the same problem with IntelliJ and Gradle. The Gradle Node Plugin referred in this answer solved my integration problem and cleaned a bit npm related tasks too.
– iaarnio
Apr 21 '17 at 7:59
add a comment |
This answer worked for me with a different npm-related task. The recommendation there is to use an executable and args rather than commandLine.
executable 'npm'
args ['install']
Depending on your directory structure, you may also need to add the workingDir property and set it to the directory where your package.json lives.
As an alternative, the Gradle Node Plugin is also really handy for managing the most common Node tasks in a Gradle build. I use this plugin as the basis for my Node tasks and then create other custom tasks as needed.
I had the same problem with IntelliJ and Gradle. The Gradle Node Plugin referred in this answer solved my integration problem and cleaned a bit npm related tasks too.
– iaarnio
Apr 21 '17 at 7:59
add a comment |
This answer worked for me with a different npm-related task. The recommendation there is to use an executable and args rather than commandLine.
executable 'npm'
args ['install']
Depending on your directory structure, you may also need to add the workingDir property and set it to the directory where your package.json lives.
As an alternative, the Gradle Node Plugin is also really handy for managing the most common Node tasks in a Gradle build. I use this plugin as the basis for my Node tasks and then create other custom tasks as needed.
This answer worked for me with a different npm-related task. The recommendation there is to use an executable and args rather than commandLine.
executable 'npm'
args ['install']
Depending on your directory structure, you may also need to add the workingDir property and set it to the directory where your package.json lives.
As an alternative, the Gradle Node Plugin is also really handy for managing the most common Node tasks in a Gradle build. I use this plugin as the basis for my Node tasks and then create other custom tasks as needed.
edited May 23 '17 at 11:46
Community♦
11
11
answered Oct 31 '16 at 15:36
Taylor714Taylor714
2,68111016
2,68111016
I had the same problem with IntelliJ and Gradle. The Gradle Node Plugin referred in this answer solved my integration problem and cleaned a bit npm related tasks too.
– iaarnio
Apr 21 '17 at 7:59
add a comment |
I had the same problem with IntelliJ and Gradle. The Gradle Node Plugin referred in this answer solved my integration problem and cleaned a bit npm related tasks too.
– iaarnio
Apr 21 '17 at 7:59
I had the same problem with IntelliJ and Gradle. The Gradle Node Plugin referred in this answer solved my integration problem and cleaned a bit npm related tasks too.
– iaarnio
Apr 21 '17 at 7:59
I had the same problem with IntelliJ and Gradle. The Gradle Node Plugin referred in this answer solved my integration problem and cleaned a bit npm related tasks too.
– iaarnio
Apr 21 '17 at 7:59
add a comment |
If you are on Windows try this:
task npmInstall(type: Exec) {
commandLine "npm.cmd", "install"
}
instead of this:
task npmInstall(type: Exec) {
commandLine "npm", "install"
}
This worked for me. I had to create.npmrc
file on the project root though to ignore thestrict-ssl
.
– Ashok M A
Oct 1 '18 at 12:57
add a comment |
If you are on Windows try this:
task npmInstall(type: Exec) {
commandLine "npm.cmd", "install"
}
instead of this:
task npmInstall(type: Exec) {
commandLine "npm", "install"
}
This worked for me. I had to create.npmrc
file on the project root though to ignore thestrict-ssl
.
– Ashok M A
Oct 1 '18 at 12:57
add a comment |
If you are on Windows try this:
task npmInstall(type: Exec) {
commandLine "npm.cmd", "install"
}
instead of this:
task npmInstall(type: Exec) {
commandLine "npm", "install"
}
If you are on Windows try this:
task npmInstall(type: Exec) {
commandLine "npm.cmd", "install"
}
instead of this:
task npmInstall(type: Exec) {
commandLine "npm", "install"
}
edited Sep 12 '18 at 5:39
Prashant Gupta
769520
769520
answered Sep 12 '18 at 4:26
Vikash MadhowVikash Madhow
625510
625510
This worked for me. I had to create.npmrc
file on the project root though to ignore thestrict-ssl
.
– Ashok M A
Oct 1 '18 at 12:57
add a comment |
This worked for me. I had to create.npmrc
file on the project root though to ignore thestrict-ssl
.
– Ashok M A
Oct 1 '18 at 12:57
This worked for me. I had to create
.npmrc
file on the project root though to ignore the strict-ssl
.– Ashok M A
Oct 1 '18 at 12:57
This worked for me. I had to create
.npmrc
file on the project root though to ignore the strict-ssl
.– Ashok M A
Oct 1 '18 at 12:57
add a comment |
If you are using Windows OS, you have to use 'npm.cmd' instead of 'npm'. Better to detect whether OS is windows or not and build your npm command. Please see the code snippet below,
import org.apache.tools.ant.taskdefs.condition.Os
task npmInstall(type: Exec) {
String npm = 'npm';
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
npm = 'npm.cmd'
}
workingDir 'src/main/webapp'
commandLine npm, 'install'
}
add a comment |
If you are using Windows OS, you have to use 'npm.cmd' instead of 'npm'. Better to detect whether OS is windows or not and build your npm command. Please see the code snippet below,
import org.apache.tools.ant.taskdefs.condition.Os
task npmInstall(type: Exec) {
String npm = 'npm';
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
npm = 'npm.cmd'
}
workingDir 'src/main/webapp'
commandLine npm, 'install'
}
add a comment |
If you are using Windows OS, you have to use 'npm.cmd' instead of 'npm'. Better to detect whether OS is windows or not and build your npm command. Please see the code snippet below,
import org.apache.tools.ant.taskdefs.condition.Os
task npmInstall(type: Exec) {
String npm = 'npm';
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
npm = 'npm.cmd'
}
workingDir 'src/main/webapp'
commandLine npm, 'install'
}
If you are using Windows OS, you have to use 'npm.cmd' instead of 'npm'. Better to detect whether OS is windows or not and build your npm command. Please see the code snippet below,
import org.apache.tools.ant.taskdefs.condition.Os
task npmInstall(type: Exec) {
String npm = 'npm';
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
npm = 'npm.cmd'
}
workingDir 'src/main/webapp'
commandLine npm, 'install'
}
answered Nov 22 '18 at 10:11
ALDRIN P VINCENTALDRIN P VINCENT
213
213
add a comment |
add a comment |
I used @ALDRIN P VINCENT answer to solve this issue. But if you need to pass command line arguments to npm script, you can do this:
Let's say following system properties are passed to gradle script
gradle test-Dsome1=dev -Dsome2=https://www.google.com
In your test script in build.gradle, you will do this:
task apifunctionaltest(type: Exec) {
String npm = 'npm';
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
npm = 'npm.cmd'
}
commandLine npm, 'run', 'test', '--', '--some1='+System.getProperty("some1"), '--some2='+System.getProperty("some2")
}
The main command starts with commandLine npm… This line equates to:
npm run test -- --some1=dev --some2=https://www.google.com
The test script in package.json also should have ‘npm install’ (it depends) command so node modules are installed before tests run. And if modules are already installed, node will not waste time and reinstall them. test script should be something like this:
"scripts": {
"test": "npm install && webpack"
}
And then you can pick those command line args thru process.argv[2]
and process.argv[3]
.
If you have a simple script like mine, then some1 and some2 will be in the 2nd and 3rd position of an array, respectively.
add a comment |
I used @ALDRIN P VINCENT answer to solve this issue. But if you need to pass command line arguments to npm script, you can do this:
Let's say following system properties are passed to gradle script
gradle test-Dsome1=dev -Dsome2=https://www.google.com
In your test script in build.gradle, you will do this:
task apifunctionaltest(type: Exec) {
String npm = 'npm';
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
npm = 'npm.cmd'
}
commandLine npm, 'run', 'test', '--', '--some1='+System.getProperty("some1"), '--some2='+System.getProperty("some2")
}
The main command starts with commandLine npm… This line equates to:
npm run test -- --some1=dev --some2=https://www.google.com
The test script in package.json also should have ‘npm install’ (it depends) command so node modules are installed before tests run. And if modules are already installed, node will not waste time and reinstall them. test script should be something like this:
"scripts": {
"test": "npm install && webpack"
}
And then you can pick those command line args thru process.argv[2]
and process.argv[3]
.
If you have a simple script like mine, then some1 and some2 will be in the 2nd and 3rd position of an array, respectively.
add a comment |
I used @ALDRIN P VINCENT answer to solve this issue. But if you need to pass command line arguments to npm script, you can do this:
Let's say following system properties are passed to gradle script
gradle test-Dsome1=dev -Dsome2=https://www.google.com
In your test script in build.gradle, you will do this:
task apifunctionaltest(type: Exec) {
String npm = 'npm';
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
npm = 'npm.cmd'
}
commandLine npm, 'run', 'test', '--', '--some1='+System.getProperty("some1"), '--some2='+System.getProperty("some2")
}
The main command starts with commandLine npm… This line equates to:
npm run test -- --some1=dev --some2=https://www.google.com
The test script in package.json also should have ‘npm install’ (it depends) command so node modules are installed before tests run. And if modules are already installed, node will not waste time and reinstall them. test script should be something like this:
"scripts": {
"test": "npm install && webpack"
}
And then you can pick those command line args thru process.argv[2]
and process.argv[3]
.
If you have a simple script like mine, then some1 and some2 will be in the 2nd and 3rd position of an array, respectively.
I used @ALDRIN P VINCENT answer to solve this issue. But if you need to pass command line arguments to npm script, you can do this:
Let's say following system properties are passed to gradle script
gradle test-Dsome1=dev -Dsome2=https://www.google.com
In your test script in build.gradle, you will do this:
task apifunctionaltest(type: Exec) {
String npm = 'npm';
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
npm = 'npm.cmd'
}
commandLine npm, 'run', 'test', '--', '--some1='+System.getProperty("some1"), '--some2='+System.getProperty("some2")
}
The main command starts with commandLine npm… This line equates to:
npm run test -- --some1=dev --some2=https://www.google.com
The test script in package.json also should have ‘npm install’ (it depends) command so node modules are installed before tests run. And if modules are already installed, node will not waste time and reinstall them. test script should be something like this:
"scripts": {
"test": "npm install && webpack"
}
And then you can pick those command line args thru process.argv[2]
and process.argv[3]
.
If you have a simple script like mine, then some1 and some2 will be in the 2nd and 3rd position of an array, respectively.
edited Dec 19 '18 at 14:01
answered Dec 18 '18 at 14:39
Faraz DurraniFaraz Durrani
2,7992937
2,7992937
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35540126%2fgradle-couldnt-execute-npm-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Does this directory exist? /Users/psilva/Documents/projects/registrolivre
– RaGe
Feb 22 '16 at 1:11