Open miejs opened 7 years ago
If npm is not in the path there may be problems when scripts want to spawn an npm process.
One example is (which led me to this issue) is customizr@1.0.0-alpha
scripts/postinstall.js
In case no npm is installed in the system, the build fails with:
8769 verbose stack Error: customizr@1.0.0-alpha postinstall: `node scripts/postinstall.js`
8769 verbose stack Exit status 1
8769 verbose stack ..
8770 verbose pkgid customizr@1.0.0-alpha
8771 verbose cwd ...
8772 error Linux 4.4.0-66-generic
8773 error argv ".../node/node" ".../node_modules/npm/bin/npm-cli.js" "install"
8774 error node v6.9.5
8775 error npm v3.10.10
8776 error code ELIFECYCLE
8777 error customizr@1.0.0-alpha postinstall: `node scripts/postinstall.js`
8777 error Exit status 1
8778 error Failed at the customizr@1.0.0-alpha postinstall script 'node scripts/postinstall.js'.
8778 error Make sure you have the latest version of node.js and npm installed.
8778 error If you do, this is most likely a problem with the customizr package,
8778 error not with npm itself.
8778 error Tell the author that this fails on your system:
8778 error node scripts/postinstall.js
8778 error You can get information on how to open an issue for this project with:
8778 error npm bugs customizr
8778 error Or if that isn't available, you can get their info via:
8778 error npm owner ls customizr
8778 error There is likely additional logging output above.
8779 verbose exit [ 1, true ]
I'm running on this same issue (npm not on path while running npm script).
My use case is doing something like this:
"scripts": {
"build": "npm run fixenv -- engine build",
"start": "npm run fixenv -- engine start",
"fixenv": "cross-env APP_VARIABLE=$SOME_VARIABLE",
},
"dependencies": {
"cross-env": "~4.0.0",
(...)
My fix was fallback back to use <npmVersion>
So I just had an interesting issue happen to me that I believe is being caused by either this same path issue or something similar.
I have a vm that has an old version of node on it already. But I use the plugin to run my builds and tests through npm scripts and subscripts. I recently change the version on the vm to node 8 and there was a failure in my build due to something npm 5 does. Not sure if anyone else is having this issue but it would seem like a pretty nasty one.
I am running into the same issue for version 1.6. I don't have node and npm installed in the linux box. i wanted to use the plugin to install them and build my project.
If I specify the npmVersion as below:
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v9.2.0</nodeVersion>
<npmVersion>5.5.1</npmVersion>
</configuration>
</execution>
</executions>
</plugin>
I got this error message while running mvn clean install
:
[INFO] ------------------------------------------------------------------------
[INFO] Building ocelot-osca-angular 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ ocelot-osca-angular ---
[INFO]
[INFO] --- frontend-maven-plugin:1.6:install-node-and-npm (install node and npm) @ ocelot-osca-angular ---
[INFO] Installing node version v9.2.0
[INFO] Unpacking /home/idp/.m2/repository/com/github/eirslett/node/9.2.0/node-9.2.0-linux-x64.tar.gz into /home/idp/ocelot-osca/ocelot-osca-angular/node/tmp
[INFO] Copying node binary from /home/idp/ocelot-osca/ocelot-osca-angular/node/tmp/node-v9.2.0-linux-x64/bin/node to /home/idp/ocelot-osca/ocelot-osca-angular/node/node
[INFO] Installed node locally.
[INFO] Installing npm version 5.5.1
[INFO] Unpacking /home/idp/.m2/repository/com/github/eirslett/npm/5.5.1/npm-5.5.1.tar.gz into /home/idp/ocelot-osca/ocelot-osca-angular/node/node_modules
[INFO] Installed npm locally.
[INFO]
[INFO] --- frontend-maven-plugin:1.6:npm (npm install) @ ocelot-osca-angular ---
[INFO] Running 'npm install' in /home/idp/ocelot-osca/ocelot-osca-angular
[WARNING] npm WARN npm npm does not support Node.js v9.2.0
[WARNING] npm WARN npm You should probably upgrade to a newer version of node as we
[WARNING] npm WARN npm can't make any promises that npm will work with this version.
[WARNING] npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
[WARNING] npm WARN npm You can find the latest version at https://nodejs.org/
[ERROR] WARNING: You are likely using a version of node-tar or npm that is incompatible with this version of Node.js.
[ERROR] Please use either the version of npm that is bundled with Node.js, or a version of npm (> 5.5.1 or < 5.4.0) or node-tar (> 4.0.1) that is compatible with Node.js 9 and above.
[ERROR] /home/idp/ocelot-osca/ocelot-osca-angular/node/node[17964]: ../src/node_zlib.cc:437:static void node::{anonymous}::ZCtx::Init(const v8::FunctionCallbackInfo
However, if I remove the npmVersion, while mvn clean install
, I got the following errors:
[INFO] --- frontend-maven-plugin:1.6:npm (run build:prod) @ ocelot-osca-angular ---
[INFO] Running 'npm run build:prod -- --base-href /osca/' in /home/idp/ocelot-osca/ocelot-osca-angular
[INFO]
[INFO] > ocelot-osca@0.0.0 build:prod /home/idp/ocelot-osca/ocelot-osca-angular
[INFO] > npm run build -- --prod "--base-href" "/osca/"
[INFO]
[ERROR] sh: npm: command not found
[ERROR] npm ERR! file sh
[ERROR] npm ERR! code ELIFECYCLE
[ERROR] npm ERR! errno ENOENT
[ERROR] npm ERR! syscall spawn
[ERROR] npm ERR! ocelot-osca@0.0.0 build:prod: npm run build -- --prod "--base-href" "/osca/"
[ERROR] npm ERR! spawn ENOENT
[ERROR] npm ERR!
[ERROR] npm ERR! Failed at the ocelot-osca@0.0.0 build:prod script.
[ERROR] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[ERROR]
[ERROR] npm ERR! A complete log of this run can be found in:
[ERROR] npm ERR! /home/idp/.npm/_logs/2017-12-06T11_54_53_573Z-debug.log
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:38 min
[INFO] Finished at: 2017-12-06T11:54:53+00:00
[INFO] Final Memory: 16M/246M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.6:npm (run build:prod) on project ocelot-osca-angular: Failed to run task: 'npm run build:prod -- --base-href /osca/' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
UPDATE: I found the problem in the error without specifying npmVersion. In my package.json, if have following:
"scripts": {
"build": "ng build",
"build:prod": "npm run build -- --prod",
}
In the frontend-maven-plugin, I ran the "build:prod" script, which in turn run npm again. This is where npm not found by the plugin. If I change "build:prod" to not run npm again, like below: "build:prod": "ng build -- --prod" It worked well.
Adding <npmVersion>
fixed it for us: https://github.com/wikimedia/wikidata-query-rdf/commit/5b2ac6432f3a7a0ba8551c14474e6c0495f88864
We have the same issue. Using a Jenkins slave without node/npm pre-installed, it fails installing webdriverjs-helper@1.8.1
. The debug log shows the following:
27594 silly install webdriverjs-helper@1.8.1
27595 info lifecycle webdriverjs-helper@1.8.1~install: webdriverjs-helper@1.8.1
27596 verbose lifecycle webdriverjs-helper@1.8.1~install: unsafe-perm in lifecycle false
27597 verbose lifecycle webdriverjs-helper@1.8.1~install: PATH: /tmp/dashboard/portal-jsps/node/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/tmp/dashboard/portal-jsps/node_modules/webdriverjs-helper/node_modules/.bin:/tmp/dashboard/portal-jsps/node_modules/.bin:/tmp/dashboard/portal-jsps/node:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:
27598 verbose lifecycle webdriverjs-helper@1.8.1~install: CWD: /tmp/dashboard/portal-jsps/node_modules/webdriverjs-helper
27599 silly lifecycle webdriverjs-helper@1.8.1~install: Args: [ '-c', 'npm run build' ]
27600 info lifecycle webdriverjs-helper@1.8.1~install: Failed to exec install script
That path, which, ironically, lists directories inside npm's install directory, does not include npm.
Is this issue closed with https://github.com/eirslett/frontend-maven-plugin/pull/868?
Most probably yes :)
There is a difference in how/where npm is installed when using the npmVersion parameter as opposed to when omitting it. If the parameter is specified, then an npm binary is installed in/node, which is on the PATH -> all good
If the parameter is omitted, npm is not installed anywhere on the PATH -> this breaks npm scripts that reference other scripts using "npm run ...".
I'm aware there have been other issues regarding the PATH, but I didn't find any open ones regarding this crucial difference in behavior.
The obvious fix for now is to extract and host npm myself (I'm using a selfhosted mirror), and set npmVersion, but I would expect the install to work the same when npm is extracted from the node download.
I noticed this when upgrading from 0.0.26 (when the npmVersion parameter was still mandatory).
versions used: frontend-maven-plugin: 1.2 and 1.3 node: 4.2.0 and 6.9.4 npm: 2.14.7 and 3.10.10
Let me know if I can provide any further information.