npm install 在 circle ci 中失败(angular cli 项目)
npm install fails in circle ci (angular cli project)
我已经在 Angular cli 中创建了一个项目。我想用 circle ci 做 CI。该项目上传到 Bitbucket 并被 Circle CI 正确挑选。虽然构建失败。以下是 config.yml(选择 CircleCI 的 sample.yml 并对其进行了更改(添加了 ng 测试)。我假设之前由 angularcli 创建的 package.json 将安装 AngularCLI.
version: 2
jobs:
build:
#working_directory: ~/mern-starter
# The primary container is an instance of the first list image listed. Your build commands run in this container.
docker:
- image: circleci/node:7.10.0
# The secondary container is an instance of the second listed image which is run in a common network where ports exposed on the primary container are available on localhost.
#- image: mongo:3.4.4
steps:
- checkout
- run:
name: Update npm
command: 'sudo npm install -g npm@latest'
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Install npm wee
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- node_modules
test:
docker:
- image: circleci/node:7.10.0
#- image: mongo:3.4.4
steps:
- checkout
- run:
name: Test
command: ng test
#- run:
# name: Generate code coverage
# command: './node_modules/.bin/nyc report --reporter=text-lcov'
#- store_artifacts:
# path: test-results.xml
# prefix: tests
#- store_artifacts:
# path: coverage
# prefix: coverage
workflows:
version: 2
build_and_test:
jobs:
- build
- test:
requires:
- build
filters:
branches:
only: dev
错误
#!/bin/bash -eo pipefail
npm install
module.js:472
throw err;
^
Error: Cannot find module 'process-nextick-args'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js:26:23)
at Module._compile (mod
我在 npm install
步骤后看到以下行,所以我想 process-nexttick-args 已经安装了。
process-nextick-args@1.0.7 node_modules/npm/node_modules/npm-registry-client/node_modules/concat-stream/node_modules/readable-stream/node_modules/process-nextick-arg
以下配置对我有用。我使用了 CircleCI 2.0。我还在完善它,将来可能会更改答案。
version: 2
jobs:
build:
working_directory: ~/angularcli
# The primary container is an instance of the first list image listed. Your build commands run in this container.
docker:
- image: circleci/node:6-browsers
environment:
CHROME_BIN: "/usr/bin/google-chrome"
steps:
- checkout
- run:
name: Install node_modules with npm
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: Install angularcli
command: sudo npm install -g @angular/cli@latest
- run:
name: Run unit tests with karma
command: ng test
- store_test_results:
path: test-results.xml
除上述脚本外,在karma.conf.js singleRun: true
中将 singleRun 标志设置为 true,以便 Karma 在 运行 所有测试用例后退出。如果没有此标志,Karma 将以连续模式运行,ng test
停止不会结束并且超时后测试失败。
我已经在 Angular cli 中创建了一个项目。我想用 circle ci 做 CI。该项目上传到 Bitbucket 并被 Circle CI 正确挑选。虽然构建失败。以下是 config.yml(选择 CircleCI 的 sample.yml 并对其进行了更改(添加了 ng 测试)。我假设之前由 angularcli 创建的 package.json 将安装 AngularCLI.
version: 2
jobs:
build:
#working_directory: ~/mern-starter
# The primary container is an instance of the first list image listed. Your build commands run in this container.
docker:
- image: circleci/node:7.10.0
# The secondary container is an instance of the second listed image which is run in a common network where ports exposed on the primary container are available on localhost.
#- image: mongo:3.4.4
steps:
- checkout
- run:
name: Update npm
command: 'sudo npm install -g npm@latest'
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Install npm wee
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- node_modules
test:
docker:
- image: circleci/node:7.10.0
#- image: mongo:3.4.4
steps:
- checkout
- run:
name: Test
command: ng test
#- run:
# name: Generate code coverage
# command: './node_modules/.bin/nyc report --reporter=text-lcov'
#- store_artifacts:
# path: test-results.xml
# prefix: tests
#- store_artifacts:
# path: coverage
# prefix: coverage
workflows:
version: 2
build_and_test:
jobs:
- build
- test:
requires:
- build
filters:
branches:
only: dev
错误
#!/bin/bash -eo pipefail
npm install
module.js:472
throw err;
^
Error: Cannot find module 'process-nextick-args'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js:26:23)
at Module._compile (mod
我在 npm install
步骤后看到以下行,所以我想 process-nexttick-args 已经安装了。
process-nextick-args@1.0.7 node_modules/npm/node_modules/npm-registry-client/node_modules/concat-stream/node_modules/readable-stream/node_modules/process-nextick-arg
以下配置对我有用。我使用了 CircleCI 2.0。我还在完善它,将来可能会更改答案。
version: 2
jobs:
build:
working_directory: ~/angularcli
# The primary container is an instance of the first list image listed. Your build commands run in this container.
docker:
- image: circleci/node:6-browsers
environment:
CHROME_BIN: "/usr/bin/google-chrome"
steps:
- checkout
- run:
name: Install node_modules with npm
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: Install angularcli
command: sudo npm install -g @angular/cli@latest
- run:
name: Run unit tests with karma
command: ng test
- store_test_results:
path: test-results.xml
除上述脚本外,在karma.conf.js singleRun: true
中将 singleRun 标志设置为 true,以便 Karma 在 运行 所有测试用例后退出。如果没有此标志,Karma 将以连续模式运行,ng test
停止不会结束并且超时后测试失败。