CircleCI 未运行'npm run'命令



我正面临使用CircleCI实现CI/CD管道的问题。我不能在管道中执行任何'npm run'命令,而这些命令可以在我的本地系统上运行。

我已经构建了一个Angular客户端和Node/Express API。我的文件夹结构是这样设置的:
- .circleci
-- config.yml 
- client
- server
- package.json

在管道中'cd client npm install'工作,而'cd client npm run build'不工作。我的Angular项目有一个'build'脚本,命令设置为'ng build'。

但是CircleCI的日志仍然是'npm ERR!失踪的脚本:"build"'

我的服务器文件夹命令也是如此。另一个值得注意的有趣的事情是,如果我创建一个名为"installapp"的脚本,并使用命令"npm install"作为它的值,日志现在会显示为"npm ERR!"丢失的脚本:"installapp"所以'npm install'可以运行,但'npm run installapp'不行,尽管它们最终都执行了'npm install'。

有人能帮我解决这个问题吗?我在分享我的配置。Yml和所有的包。参考Json文件来帮助解决这个错误。

.circleci/config.yml

version: 2.1
orbs:
node: circleci/node@4.1.0
aws-cli: circleci/aws-cli@1.3.1
jobs:
build:
docker:
- image: "cimg/base:stable"
steps:
- node/install
- checkout
- aws-cli/setup
- run:
name: Front-End Install
command: |
npm run frontend:install
- run:
name: Back-End Install
command: |
npm run backend:install
- run:
name: Front-End Build
command: |
npm run frontend:build
- run:
name: Back-End Build
command: |
npm run backend:build
- run:
name: Deploy App
command: |
npm run frontend:deploy
npm run backend:deploy

根应用的package.json

{
"scripts": {
"frontend:install": "cd client && npm install",
"backend:install": "cd server && npm install",
"frontend:build": "cd client && npm run build",
"backend:build": "cd server && npm run build",
"frontend:deploy": "cd client && npm run deploy",
"backend:deploy": "cd server && npm run deploy"
}
}

客户端包。json(角)

{
"name": "guitar-store-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"lint": "ng lint",
"deploy": "chmod +x ./bin/deploy.sh && ./bin/deploy.sh"
},
"private": true,
"dependencies": {
"@angular/animations": "~12.2.0",
"@angular/common": "~12.2.0",
"@angular/compiler": "~12.2.0",
"@angular/core": "~12.2.0",
"@angular/forms": "~12.2.0",
"@angular/platform-browser": "~12.2.0",
"@angular/platform-browser-dynamic": "~12.2.0",
"@angular/router": "~12.2.0",
"@auth0/angular-jwt": "^5.0.2",
"rxjs": "~6.6.0",
"tslib": "^2.3.0",
"w3-css": "^4.1.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~12.2.1",
"@angular-eslint/builder": "12.3.1",
"@angular-eslint/eslint-plugin": "12.3.1",
"@angular-eslint/eslint-plugin-template": "12.3.1",
"@angular-eslint/schematics": "12.3.1",
"@angular-eslint/template-parser": "12.3.1",
"@angular/cli": "~12.2.1",
"@angular/compiler-cli": "~12.2.0",
"@types/jasmine": "~3.8.0",
"@types/node": "^12.11.1",
"@typescript-eslint/eslint-plugin": "4.28.2",
"@typescript-eslint/parser": "4.28.2",
"eslint": "^7.26.0",
"jasmine-core": "~3.8.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.3.5"
}
}

服务器包。json(节点/表达)

{
"name": "storefront-backend-api",
"version": "1.0.0",
"description": "An e-commerce API",
"main": "build/server/app.js",
"engines": {
"node": ">=14.17.1",
"npm": ">=6.14.13"
},
"scripts": {
"lint": "eslint src/**/*.ts",
"prettier": "prettier --config .prettierrc src/**/*.ts --write",
"build": "npx tsc",
"jasmine": "jasmine",
"test-local": "set ENV=test&& db-migrate db:create guitar_shop_test && db-migrate --env test up && npm run jasmine && db-migrate db:drop guitar_shop_test",
"start": "node build/server/app.js",
"deploy": "chmod +x ./bin/deploy.sh && ./bin/deploy.sh"
},
"repository": {
"type": "git",
"url": "git+https://github.com/siddube/full-stack-app-server.git"
},
"keywords": [
"Image",
"Resize"
],
"author": "siddube",
"license": "ISC",
"bugs": {
"url": "https://github.com/siddube/full-stack-app-server/issues"
},
"homepage": "https://github.com/siddube/full-stack-app-server#readme",
"devDependencies": {
"@types/bcrypt": "^5.0.0",
"@types/cors": "^2.8.12",
"@types/express": "^4.17.12",
"@types/jasmine": "^3.7.7",
"@types/jsonwebtoken": "^8.5.4",
"@types/node": "^16.0.0",
"@types/pg": "^8.6.1",
"@types/supertest": "^2.0.11",
"@types/underscore": "^1.11.3",
"@typescript-eslint/eslint-plugin": "^4.28.2",
"@typescript-eslint/parser": "^4.28.2",
"db-migrate-pg": "^1.2.2",
"dotenv": "^10.0.0",
"eslint": "^7.30.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"jasmine-ts": "^0.4.0",
"nodemon": "^2.0.13",
"prettier": "^2.3.2",
"ts-node": "^10.0.0",
"typescript": "^4.3.5"
},
"dependencies": {
"bcrypt": "^5.0.1",
"cors": "^2.8.5",
"db-migrate": "^1.0.0-beta.16",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"jasmine": "^3.8.0",
"jasmine-spec-reporter": "^7.0.0",
"jsonwebtoken": "^8.5.1",
"pg": "^8.7.1",
"supertest": "^6.1.5",
"underscore": "^1.13.1"
},
"eslintIgnore": [
"**/*[sS]pec.ts",
"reporter.ts"
]
}

我认为主要问题是我不能运行在这些文件中定义的'npm run'脚本。当日志提示我检查可用的npm run命令时,所有这些命令都会显示出来。'npm install'也可以。

希望能得到一些帮助或建议来解决这个问题。谢谢!

我很抱歉,但这是一个真正的CircleCI新手错误。我的客户端和服务器文件夹本身就是git存储库,根应用程序会在实例化管道时为它们创建空文件夹。通过创建两个新文件夹并在没有旧git存储库的情况下复制文件来解决这个问题,并且它工作得很好。

在我看来,这是我第一次实现一个CI/CD管道。

相关内容

  • 没有找到相关文章

最新更新