尝试为angular 4项目配置frontend-maven-plugin时 该插件试图执行一个名为load(“npm run load”)的脚本,该脚本在package.json中不存在。 添加脚本时,构建成功通过。 有没有办法告诉插件不运行这个脚本?
这是我的package.json文件
{
"name": "historage-ui",
"version": "1.0.0-SNAPSHOT",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.0.0",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "1.1.3",
"@angular/compiler-cli": "^4.0.0",
"@angular/language-service": "^4.0.0",
"@types/jasmine": "2.5.45",
"@types/node": "~6.0.60",
"codelyzer": "~3.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.0.4",
"tslint": "~5.3.2",
"typescript": "~2.3.3"
}
}
这是插件配置:
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<!-- optional -->
<configuration>
<workingDirectory>src/main/historage-ui</workingDirectory>
</configuration>
<executions>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<!-- optional: default phase is "generate-resources" -->
<phase>generate-resources</phase>
<configuration>
<!-- optional: The default argument is actually
"install", so unless you need to run some other npm command,
you can remove this whole <configuration> section.
-->
<arguments>install</arguments>
</configuration>
</execution>
</executions>
</plugin>
这是堆栈跟踪: [错误]无法在项目上执行目标com.github.eirslett:frontend-maven-plugin:1.0:npm(npm run load)historage_ui-js:无法运行任务:'npm run load --proxy = htp:// b77553: @ 10.255.123.73:8080'失败。 (错误代码1) - &gt; [帮助1] org.apache.maven.lifecycle.LifecycleExecutionException:无法执行目标com.github.eirslett:frontend-maven-plugin:1.0:npm(npm run load)项目historage_ui-js:无法运行任务 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212) 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108) 在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76) 在org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) 在org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116) 在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361) 在org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155) 在org.apache.maven.cli.MavenCli.execute(MavenCli.java:584) 在org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213) 在org.apache.maven.cli.MavenCli.main(MavenCli.java:157) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) 在org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 在org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 在org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 在org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 在org.codehaus.classworlds.Launcher.main(Launcher.java:46) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) 在com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) 引起:org.apache.maven.plugin.MojoFailureException:无法运行任务 在com.github.eirslett.maven.plugins.frontend.mojo.AbstractFrontendMojo.execute(AbstractFrontendMojo.java:95) 在org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133) 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ......还有25个 引起:com.github.eirslett.maven.plugins.frontend.lib.TaskRunnerException:'npm run load --proxy = htp:// b77553: @ 10.255.123.73:8080'失败。 (错误代码1) 在com.github.eirslett.maven.plugins.frontend.lib.NodeTaskExecutor.execute(NodeTaskExecutor.java:60) 在com.github.eirslett.maven.plugins.frontend.mojo.NpmMojo.execute(NpmMojo.java:62) 在com.github.eirslett.maven.plugins.frontend.mojo.AbstractFrontendMojo.execute(AbstractFrontendMojo.java:89)
答案 0 :(得分:0)
应该在脚本中调用Npm install来修复