首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >前端-maven-plugin无法安装npm

前端-maven-plugin无法安装npm
EN

Stack Overflow用户
提问于 2020-02-04 23:45:52
回答 4查看 14.8K关注 0票数 4

我可以使用命令行在我的项目上运行npm installnpm run build,但是当我尝试使用前端-maven-plugin时,它失败了,错误如下

代码语言:javascript
复制
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] app_name                                                          [pom]
[INFO] frontend                                                           [jar]
[INFO] backend                                                            [jar]
[INFO] 
[INFO] ---------------------< com.flareback-domain:app_name >----------------------
[INFO] Building app_name 1.0-SNAPSHOT                                    [1/3]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ app_name ---
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ app_name ---
[INFO] Installing /Users/flareback/code/app_name/pom.xml to /Users/flareback/.m2/repository/com/flareback-domain/app_name/1.0-SNAPSHOT/app_name-1.0-SNAPSHOT.pom
[INFO] 
[INFO] ----------------------< com.flareback-domain:frontend >----------------------
[INFO] Building frontend 1.0-SNAPSHOT                                     [2/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ frontend ---
[INFO] Deleting /Users/flareback/code/app_name/frontend/target
[INFO] 
[INFO] --- frontend-maven-plugin:1.9.1:install-node-and-npm (install node and npm) @ frontend ---
[INFO] Node v12.14.1 is already installed.
[INFO] 
[INFO] --- frontend-maven-plugin:1.9.1:npm (npm install) @ frontend ---
[INFO] Running 'npm install' in /Users/flareback/code/app_name/frontend
[INFO] internal/modules/cjs/loader.js:796
[INFO]     throw err;
[INFO]     ^
[INFO] 
[INFO] Error: Cannot find module './internal/streams/buffer_list'
[INFO] Require stack:
[INFO] - /Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js
[INFO] - /Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/readable-stream/readable.js
[INFO] - /Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/tracker-stream.js
[INFO] - /Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js
[INFO] - /Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/index.js
[INFO] - /Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/npmlog/log.js
[INFO] - /Users/flareback/code/app_name/frontend/node/node_modules/npm/bin/npm-cli.js
[INFO]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
[INFO]     at Function.Module._load (internal/modules/cjs/loader.js:686:27)
[INFO]     at Module.require (internal/modules/cjs/loader.js:848:19)
[INFO]     at require (internal/modules/cjs/helpers.js:74:18)
[INFO]     at Object.<anonymous> (/Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js:72:18)
[INFO]     at Module._compile (internal/modules/cjs/loader.js:955:30)
[INFO]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
[INFO]     at Module.load (internal/modules/cjs/loader.js:811:32)
[INFO]     at Function.Module._load (internal/modules/cjs/loader.js:723:14)
[INFO]     at Module.require (internal/modules/cjs/loader.js:848:19) {
[INFO]   code: 'MODULE_NOT_FOUND',
[INFO]   requireStack: [
[INFO]     '/Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js',
[INFO]     '/Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/readable-stream/readable.js',
[INFO]     '/Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/tracker-stream.js',
[INFO]     '/Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js',
[INFO]     '/Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/index.js',
[INFO]     '/Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/npmlog/log.js',
[INFO]     '/Users/flareback/code/app_name/frontend/node/node_modules/npm/bin/npm-cli.js'
[INFO]   ]
[INFO] }
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for app_name 1.0-SNAPSHOT:
[INFO] 
[INFO] app_name ........................................... SUCCESS [  0.279 s]
[INFO] frontend ........................................... FAILURE [  0.438 s]
[INFO] backend ............................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.902 s
[INFO] Finished at: 2020-02-04T10:34:21-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.9.1:npm (npm install) on project frontend: Failed to run task: 'npm install' 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
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :frontend

我的前端pom文件

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <artifactId>frontend</artifactId>

    <parent>
        <artifactId>app_name</artifactId>
        <groupId>com.flareback-domain</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <frontend-maven-plugin.version>1.9.1</frontend-maven-plugin.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>${frontend-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>v12.14.1</nodeVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>install</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm run build</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run build</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
EN

回答 4

Stack Overflow用户

发布于 2020-02-05 23:43:58

我将pom更改为使用不同的节点版本。

<nodeVersion>v9.11.1</nodeVersion>

然后我运行了mvn clean install。这失败了,但它通过了安装部分,并在运行构建时失败。然后我切换回<nodeVersion>v12.14.1</nodeVersion>并重新运行mvn clean install,它工作了。

票数 2
EN

Stack Overflow用户

发布于 2020-10-06 11:52:57

我升级了Node LTS版本,现在它可以工作了。

票数 0
EN

Stack Overflow用户

发布于 2020-11-04 03:36:42

这是节点版本问题。也可能是您的全局节点版本不匹配。

我已经用node版本10.16.0实现了以下代码

代码语言:javascript
复制
<plugin>
            <groupId>com.github.eirslett</groupId>
            <artifactId>frontend-maven-plugin</artifactId>
            <version>1.7.6</version>
            <configuration>
                <nodeVersion>v10.16.0</nodeVersion>
                <npmVersion>6.10.2</npmVersion>
                <workingDirectory>./angular</workingDirectory>
            </configuration>
            <executions>
            
                <execution>
                    <id>install node and npm</id>
                    <goals>
                        <goal>install-node-and-npm</goal>
                    </goals>
                    <phase>generate-resources</phase>
                </execution>
        
        
                <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <arguments>install</arguments>
                        </configuration>
                </execution> 
        
    
                <execution>
                    <id>npm run-script build</id>
                    <goals>
                        <goal>npm</goal>
                    </goals>
                    <phase>generate-resources</phase>
                    <configuration>
                        <arguments>run-script build</arguments>
                    </configuration>
                </execution>
            </executions>
        </plugin>

如果仍然不起作用,请尝试使用force属性清除npm缓存

代码语言:javascript
复制
npm cache clean --force

感谢您的阅读。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60060927

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档