ng无法识别为内部或外部命令. Jenkins + Angular CLI [英] ng is not recognised as an internal or external command. Jenkins + Angular CLI
问题描述
我正在尝试为Angular CLI项目设置Jenkins.我已经在特定用户帐户下的Jenkins服务器上安装了node和Angular Cli. 如果我在服务器上打开命令提示符,请执行以下命令以验证它们是否已正确安装,这就是结果:
I am trying to setup Jenkins for an Angular CLI project. I have installed node and Angular Cli on the Jenkins server under a specific user account. if I open a command prompt on the server an execute the following commands to verify they are installed properly, this is the result:
我已经用Jenkins配置了该项目,并且创建了两个构建步骤,两个执行了两个bat文件.
I have configured the project with Jenkins, and i created two build steps two execute two bat files.
一次运行:npm install
One runs: npm install
第二个运行:ng build --prod
and the second one runs: ng build --prod
然后我构建Jenkins,它运行npm install,但是运行ng build --prod失败,因为它说'ng'不被识别为内部或外部命令".
Then I build Jenkins, it runs the npm install but it fails running ng build --prod because it says " 'ng' is not recognised as an internal or external command".
我做错什么了吗?还有另一种方法可以在node_modules文件夹上使用angular cli,因此不需要使用服务器上安装的angular cli.似乎仅为我的用户在服务器上安装了Angular CLI,但没有为Jenkins用来构建的用户安装.
Am I doing something wrong? Is there another way to probably use the angular cli on the node_modules folder, So it does not need to use the angular cli installed on the server. It seems like Angular CLI is installed only for my user on the server but not for the user Jenkins use to build.
PS:我使用以下命令全局安装了Angular CLI:
PS: I installed Angular CLI globally using:
npm i -g @ angular/cli
npm i -g @angular/cli
推荐答案
无需在服务器上安装angular cli,只需运行
No need to install angular cli on server, just run
npm run ng -- build
这将运行项目devDependencies
这样,您可以将任何标志传递到本地cli npm run ng -- test
,npm run ng -- lint
等
This way you can pass any flag to your local cli npm run ng -- test
, npm run ng -- lint
, etc
您可以像这样将其他标志传递给
ng
run ng -- build --prod
You can pass additional flags to
ng
just like that
run ng -- build --prod
更多详细信息,请参见 https://docs.npmjs.com/cli/run-script
More details at https://docs.npmjs.com/cli/run-script
这篇关于ng无法识别为内部或外部命令. Jenkins + Angular CLI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!