Running a projetct with IntelliJ gives "Execution failed for task ':npmInstall'." but the same project runs ok when started by command line - intellij-idea

I have a jhipster project that runs just fine when started by the command line "./gradlew" (Ubuntu 20.04.3) but when I start the debbug from the IntelliJ (community) it returns the follow message:
What went wrong:
Execution failed for task ':npmInstall'.
A problem occurred starting process 'command 'npm''
And I need to run it on IntelliJ to use breakpoints and debug.
What I have tried:
I have checked the java version on the IntelliJ compiller
I have the PATH's set correct (I can run other projects)

After trying to redefine things, deleting the "node-modules" folder, 'invalidating and restart' on intelliJ and even checking-out the entire project from git, what did the trick was to change the block on build.gradle, from:
if (project.hasProperty("nodeInstall")) {
node {
version = "14.16.0"
npmVersion = "7.8.0"
download = true
}
}
to
node {
version = "14.16.0"
npmVersion = "7.8.0"
download = true
}
That fixed the problem and now I can debbug using intelliJ

Related

alternate way to set Build and run using IntelliJ IDEA

I am working with Java source code with TestNG and frequently see errors like no test found to run OR Test event were not received whenever I try to run test cases in IntelliJ IDEA.
Which I can fix with changing Build and run using IntelliJ IDEA from Gradle.
I am looking for alternative way using which can add this somewhere as configuration instead of going and changing this manually.
You can use gradle-idea-ext-plugin to set build and run actions right in the Gradle build script:
import static org.jetbrains.gradle.ext.ActionDelegationConfig.TestRunner.CHOOSE_PER_TEST
plugins {
...
id "org.jetbrains.gradle.plugin.idea-ext" version "1.0"
...
}
idea.project.settings {
delegateActions {
delegateBuildRunToGradle = true // Delegate Run/Build to Gradle
testRunner = CHOOSE_PER_TEST // Test execution: PLATFORM, GRADLE or CHOOSE_PER_TEST
}
}
But actually, the fact that it works with IDE runner, but does not work with Gradle runner may indicate problems. I would first check if it works from the command line Gradle - make sure you run the same test with it as from the IDE. If it works in terminal but does not work in IDE, I would report a bug at YouTrack with reproducible sample.

How run flutter 'packages pub run build_runner build' with debug mode in intellij idea?

I want to put break point on my generator code, but I don't know how to run the command on the debug mode.
I wrote generator using source_gen and build_runner
class MyGenerator extends GeneratorForAnnotation<Todo> {
#override
FutureOr<String> generateForAnnotatedElement(
Element element, ConstantReader annotation, BuildStep buildStep) {
return "// Hey! Annotation found!";
}
}
run commad flutter packages pub run build_runner build*
copy build.dart to root folder of project
add new run configuration
run debug, now you can debug your code generator!
* the packages is optional, you can just run flutter pub run build_runner build
Ivan's answer worked for me, but every time I changed a file that was using an annotation - the build process outputted:
[SEVERE] Terminating builds due to build script update
[INFO] Terminating. No further builds will be scheduled
and then renamed the build script itself from build.dart to build.dart.cached, and then exit with code 75.
After digging through the build_runner code, I discovered that this behavior can be mitigated by using the following Program Arguments:
serve --skip-build-script-check
(i.e. instead of just serve as Ivan suggested).
There may be some negative consequences; in the build_runner source code, in options.dart, I saw this:
// For testing only, skips the build script updates check.
bool skipBuildScriptCheck;

IntelliJ Kotlin/JS Mocha Unit Testing Unavailable via Plugin

I am experiencing some difficulty getting IntelliJ to recognize my Kotlin Tests as mocha tests and generating the green play button in the gutter allowing me to run Kotlin/JS unit tests in the IDE via the Mocha Plugin. Now, I somehow managed to get this working after some trial and error and then inexplicable earlier today it just stopped working and the green play buttons vanished from the gutter. I have tried all the normal stuff such as invalidating the IDE cache, removing .idea/*.iml files and reimporting project. Nothing seems to work.
Image of Working Environment
here is an image of the setup working as expected that I luckily took a snapshot of while I had the chance because I had so much difficulty getting it working.
You can also see that the mocha run configuration is accurately picking up on the fact that the actual file being ran is going to be the output file in my build directory.
My initial instinct led me to believe that this was due to IntelliJ picking up on my map.js files being generated as well, however this is not the case as did not (and do not) have my compile options set to with sourceMap = true or sourceMapEmbedSources = "always", as you can see from this snippet from my build.gradle.kts
compileKotlin2Js {
kotlinOptions {
moduleKind = "commonjs"
}
}
compileTestKotlin2Js {
kotlinOptions {
moduleKind = "commonjs"
}
}
For the record, my gradle build compiles and tests run successfully. To clarify, I am specifically trying to get IntelliJ to recognize the project structure in such a way that the run configurations can make these education decisions for me and speed up my workflow.

Intelij IDEA scala test - compilation error, but ok in sbt

I'm getting following compilation error in Intelij Idea when running scalatests in my play framework application:
Error:(41, 54) Cannot find an instance of play.api.libs.json.JsObject
to WSBody. Define a BodyWritable[play.api.libs.json.JsObject] or
extend play.api.libs.ws.ahc.DefaultBodyWritables
val response = await(wsClient.url(testUrl).post(data))
Though when running sbt test it compiles and runs fine.
I've tried to clear Intelij cache and restart, didn't help.
What can be an issue?
I could resolve this issue by deleting .idea folder and re-importing the project.

Configuring Erlang plugin for Intellij

I am trying to set-up an Erlang project in IntelliJ 15. I am running windows.
I have built Rebar. trying escript.exe "//rebar_path//" --version returns the version number. Erlang also works on command line. In Settings->Other-settings->Erlang External tools I have the address of rebar file and IntelliJ detects the version number alright.
For my hello-world Erlang App, I have added an Erlang console application which runs fine and gives me
D:/Program Files/erl7.2.1\bin\erl" -pa E:/Documents/Projects/Erlang_test/out/production/Erlang_test -pa E:/Documents/Projects/Erlang_test
at the top. However attempting to call the functions gives me:
exception error: undefined function hello:hello2/0
It's as if compilation does not happen. I also tried setting up an "Erlang Rebar" Run configuration with compile as the command. It outputs:
*"D:\Program Files\erl7.2.1\bin\escript.exe"
E:\Documents\Projects\rebar_source\rebar c*
at the top, followed by the error:
escript: Error executing 'D:\Program': 193
What am I doing wrong?
update: I tried adding the rebar.cmd as an external tool to run it before the run configuration. After doing some research, I tried adding a rebar.config file with:
{sub_dirs, ["src" ] }.
to match the project structure.
Running the tool with compile on its own outputs: (configuration page screenshot)
==>src (compile)
==> Erlang_test (compile)
I was expecting to get: Compiled src/hello.erl but I neither get that, nor do I see any bean files created anywhere; and if I try running hello:hello() in the "Erlang console" run configuration gives me:
exception error: undefined function hello:hello2/0