I have a maven project using maven-frontend-plugin to install all node (npm packages) and run all npm tests. Under linux fail due cygwin command.
Inside pom the maven-frontend-plugin configuration is defined and during the build an error arise after install npm and trying to run test with mocha.
If one try to run the tests directly with Node works whatever environment Using "mvn clean package" it fails on linux
Under Windows, without any previous installation works.
Inside pom
```xml
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>${frontend-maven-plugin.version}</version>
<executions>
<!-- Install Node and npm -->
<execution>
<id>install-node-npm</id>
<goals><goal>install-node-and-npm</goal></goals>
<configuration>
<nodeVersion>${frontend-maven-plugin.node.version}</nodeVersion>
<npmVersion>${frontend-maven-plugin.npm.version}</npmVersion>
</configuration>
</execution>
<!-- Install npm modules -->
<execution>
<id>npm-install-modules</id>
<goals>
<goal>npm</goal>
</goals>
</execution>
<!-- lint && mocha && nyc coverage -->
<execution>
<id>npm run-script lint</id>
<phase>test</phase>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run-script lint</arguments>
</configuration>
</execution>
<execution>
<id>npm run-script test:coverage</id>
<phase>test</phase>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run-script test:coverage</arguments>
</configuration>
</execution>
<!-- build angular application -->
<execution>
<id>npm run-script prod</id>
<phase>prepare-package</phase>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run-script prod</arguments>
</configuration>
</execution>
</executions>
```
Inisde package.json
```json
scripts:{
...
"test:coverage": "nyc npm run-script test:mocha || exit 0",
...
}
```
Linux fail:
nyc npm run-script test:mocha
ERROR : <base_path>/node/npm:2
(set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix
SyntaxError: Unexpected identifier
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Module.replacementCompile (node_modules/append-transform/index.js:58:13)
at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Object.<anonymous> (node_modules/append-transform/index.js:62:4)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
SOLVED
Using a recent version the troubles dissapears on Ubuntu
<frontend-maven-plugin.version>1.7.6</frontend-maven-plugin.version>
Using Kubernetes pod with maven installed without any Node previous installation is still not working. Note that it works for all other projects without nyc and mocha.
I'm still looking for what is missing
-
Solved using a recent version <frontend-maven-plugin.version>1.7.6</frontend-maven-plugin.version>Caperutxa– Caperutxa2019年05月15日 10:50:58 +00:00Commented May 15, 2019 at 10:50
1 Answer 1
The problem inside Kubernetes pod is related to the path.
Set the correct NODE_PATH value as environment variable the process works so nice
Comments
Explore related questions
See similar questions with these tags.