question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NPM fails on command with 'npm run <task>'

See original GitHub issue

Prerequisites:

  1. Maven configuration:
<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>v0.12.2</nodeVersion>
              <npmVersion>2.7.6</npmVersion>
            </configuration>
          </execution>
          <execution>
            <id>npm install</id>
            <goals>
              <goal>npm</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
  1. package.json:
...
"scripts": {
    "postinstall": "npm run wiredep",
    "prestart": "npm install",
    "start": "http-server -a 127.0.0.1 -p 8002",
    "wiredep": "wiredep --verbose --bowerJson bower.json --src src/main/resources/public/index.html"
  }
...
  1. Node.js/npm is not installed globally.

While running ‘mvn install’ the following error is thrown:

[INFO] --- frontend-maven-plugin:0.0.23:npm (npm install) @ project-web-client ---
[INFO] Running 'npm install --color=false' in C:\work\projects\project-web-client
[INFO]
[INFO] > project-web-client@4.0.11-SNAPSHOT postinstall C:\work\projects\project-web-client
[INFO] > bower install && npm run wiredep
[INFO]
[ERROR] 'npm' is not recognized as an internal or external command,
[ERROR] operable program or batch file.
[ERROR]
[ERROR] npm ERR! Windows_NT 6.3.9600
[ERROR] npm ERR! argv "C:\\work\\projects\\project-web-client\\node\\node" "C:\\work\\projects\\project-web-client\\node\\npm\\bin\\npm-cli.js" "install" "--color=
false"
[ERROR] npm ERR! node v0.12.2
[ERROR] npm ERR! npm  v2.7.6
[ERROR] npm ERR! code ELIFECYCLE
[ERROR] npm ERR! project-web-client@0.0.11-SNAPSHOT postinstall: `bower install && npm run wiredep`
[ERROR] npm ERR! Exit status 1

Note: if package.json has a command in postinstall phase like ‘bower install’ it works correctly.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
eirslettcommented, May 18, 2015

Copy this file: https://github.com/eirslett/frontend-maven-plugin/blob/master/frontend-maven-plugin/src/it/example project/helper-scripts/npm into your project root directory (the same directory as the pom.xml file and/or the package.json file) and try again!

If you’re building on Windows, you should add this as well: https://github.com/eirslett/frontend-maven-plugin/blob/master/frontend-maven-plugin/src/it/example project/helper-scripts/npm.cmd

Then try running the maven build again. If that works, commit these two files into your repository.

0reactions
sghosh-01commented, Mar 30, 2017

Here is my pom:

              <groupId>com.github.eirslett</groupId>
              <artifactId>frontend-maven-plugin</artifactId>
              <version>1.4</version>
              <executions>
               <execution>
                  <id>install node and npm</id>
                  <phase>generate-resources</phase>
                  <goals>
                    <goal>install-node-and-npm</goal>
                  </goals>
                  <configuration>
                    <nodeVersion>v6.9.5</nodeVersion>
                    <npmVersion>3.10.10</npmVersion>
                    <workingDirectory></workingDirectory>
                  </configuration>
                </execution>

                <execution>
                  <id>npm install</id>
                  <phase>generate-resources</phase>
                  <goals>
                    <goal>npm</goal>
                  </goals>
                  <configuration>
                    <workingDirectory></workingDirectory>
                  </configuration>
                </execution>

The second execution, npm install doesn’t run. When I run “mvn clean install” I get the following — frontend-maven-plugin:1.4:install-node-and-npm (install node and npm) @ myproject — [INFO] Node v6.9.5 is already installed. [INFO] NPM 3.10.10 is already installed. [INFO] [INFO] — frontend-maven-plugin:1.4:npm (npm install) @ myproject — [INFO] Running ‘npm install’ in /Users/myproject

Waited more than 30 mins but doesn’t do anything after this. Tried few times and it is same each time. Would appreciate any help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm-run-script
Description. This runs an arbitrary command from a package's "scripts" object. If no "command" is provided, it will list the available scripts.
Read more >
VS Code automatic npm build fails with "npm command not ...
The issue is likely because npm isn't in VS Code's path (likely /usr/bin ). However, you can create a custom build task and...
Read more >
Unable to run npm test as a task. - Atlassian Community
I'm currently trying to run 'npm test' as a task. The command is simply 'test'. When I try to run my build plan...
Read more >
how do I execute an npm run script from a VSTS build task?
Open powershell prompt on your machine, and then type the npm commands. They should fail with the same error.. Click to vote up....
Read more >
Re: [Opencast] Failed to run task: 'npm run build --no-color
To address your issue, we need the part of the build above the list of modules to tell exactly what's going wrong, but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found