Angular Bitbucket 管道无法 运行 ng 构建
Angular Bitbucket Pipeline unable to run ng build
我已经创建了一个管道,通过 bitbucket 管道将我的 angular 应用程序部署到我的 ftp 服务器。因此我创建了这个 pipeline.yml 文件:
image: node:6.9.4 # we need node image to run our angular application in
clone: # help to clone our source here
depth: full
pipelines: # We set up all the pipeline or actions beneath
default: # here most always trigger before any other pipeline
- step:
script:
- echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'."
branches: # This is branch specific configuration, we can set for different branches and different actions when we push codes
master:
- step:
script:
- npm install -g @angular/cli
- npm install
- ng build --prod
- echo "Let's go in to our dist/ and initialize there with git"
- cd dist/
- git config --global user.email "account@clate.de"
- git config --global user.name "clate"
- git init
- git add -A && git commit -m "base url updated for prod deployment"
- git clone https://github.com/git-ftp/git-ftp.git
- cd git-ftp
- git checkout 1.3.4
- make install
- echo "Done with installation of git-ftp"
- cd ../
- rm -rf git-ftp
- git config git-ftp.url "ftp://188.40.30.32/test"
- git config git-ftp.user $FTP_USERNAME
- git config git-ftp.password $FTP_PASSWORD
- git ftp push --auto-init
不幸的是,我在尝试 运行 命令 ng build --prod
时收到一个错误,它显示了这个错误:
+ ng build --prod
/usr/local/lib/node_modules/@angular/cli/bin/ng:23
);
^
SyntaxError: Unexpected token )
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
我已经尝试在本地 运行 它并且没有任何问题。
您的项目中安装了 angular cli,更好更快的方法是使用本地 ng 安装来构建您的项目。只需添加一个 npm 脚本并通过 npm 调用构建,如下所示:
//package.json
"scripts": {
"build:prod": "ng build --prod",
...
}
pipeline.yml
- npm install -g @angular/cli <---THIS IS NO LONGER NEEDED
- npm install
- npm run build:prod
....
我已经创建了一个管道,通过 bitbucket 管道将我的 angular 应用程序部署到我的 ftp 服务器。因此我创建了这个 pipeline.yml 文件:
image: node:6.9.4 # we need node image to run our angular application in
clone: # help to clone our source here
depth: full
pipelines: # We set up all the pipeline or actions beneath
default: # here most always trigger before any other pipeline
- step:
script:
- echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'."
branches: # This is branch specific configuration, we can set for different branches and different actions when we push codes
master:
- step:
script:
- npm install -g @angular/cli
- npm install
- ng build --prod
- echo "Let's go in to our dist/ and initialize there with git"
- cd dist/
- git config --global user.email "account@clate.de"
- git config --global user.name "clate"
- git init
- git add -A && git commit -m "base url updated for prod deployment"
- git clone https://github.com/git-ftp/git-ftp.git
- cd git-ftp
- git checkout 1.3.4
- make install
- echo "Done with installation of git-ftp"
- cd ../
- rm -rf git-ftp
- git config git-ftp.url "ftp://188.40.30.32/test"
- git config git-ftp.user $FTP_USERNAME
- git config git-ftp.password $FTP_PASSWORD
- git ftp push --auto-init
不幸的是,我在尝试 运行 命令 ng build --prod
时收到一个错误,它显示了这个错误:
+ ng build --prod
/usr/local/lib/node_modules/@angular/cli/bin/ng:23
);
^
SyntaxError: Unexpected token )
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
我已经尝试在本地 运行 它并且没有任何问题。
您的项目中安装了 angular cli,更好更快的方法是使用本地 ng 安装来构建您的项目。只需添加一个 npm 脚本并通过 npm 调用构建,如下所示:
//package.json
"scripts": {
"build:prod": "ng build --prod",
...
}
pipeline.yml
- npm install -g @angular/cli <---THIS IS NO LONGER NEEDED
- npm install
- npm run build:prod
....