kan*_*ano 6 npm gitlab docker eslint vue-cli
我正在尝试创建一个 GitLab CI/CD 阶段,它只会检查我的代码并在所有其他步骤之前运行。问题是,出于速度优化的原因,我试图在预构建的图像上进行 linting(及其配置)。
我的.gitlab-ci.yml
stages:
- prelint
- lint
- build
- deploy
build-linter:
stage: prelint
script: echo 'This builds the linter image'
only:
changes:
- Dockerfile.lint
lint:
stage: lint
image: prebuilt-linter
script:
- npm run lint
Run Code Online (Sandbox Code Playgroud)
以及内容Dockerfile.lint:
FROM node:lts-alpine
RUN npm i -g eslint \
prettier \
@babel/core \
core-js \
core-js-compat@3.4.7 \
eslint-config-prettier \
eslint-plugin-prettier \
eslint-plugin-vue \
@vue/cli-service \
@vue/cli-plugin-eslint \
@vue/cli-plugin-babel \
@vue/cli-plugin-unit-jest \
@vue/cli-plugin-e2e-nightwatch \
@vue/eslint-config-prettier \
babel-eslint
WORKDIR /app
CMD eslint
Run Code Online (Sandbox Code Playgroud)
但是,它目前出错了,因为我认为它正在尝试从项目自己的node_modules/目录中查找依赖项,并且不会使用全局安装的依赖项。
$ npm run lint
00:01
> @project/1.0.0 lint /builds/frontend
> vue-cli-service lint
ERROR Error: Cannot find module '@vue/cli-plugin-babel/preset' from '/builds/frontend'
Error: Cannot find module '@vue/cli-plugin-babel/preset' from '/builds/frontend'
at Function.resolveSync [as sync] (/usr/local/lib/node_modules/@babel/core/node_modules/resolve/lib/sync.js:81:15)
at resolveStandardizedName (/usr/local/lib/node_modules/@babel/core/lib/config/files/plugins.js:101:31)
at resolvePreset (/usr/local/lib/node_modules/@babel/core/lib/config/files/plugins.js:58:10)
at loadPreset (/usr/local/lib/node_modules/@babel/core/lib/config/files/plugins.js:77:20)
at createDescriptor (/usr/local/lib/node_modules/@babel/core/lib/config/config-descriptors.js:154:9)
at /usr/local/lib/node_modules/@babel/core/lib/config/config-descriptors.js:109:50
at Array.map (<anonymous>)
at createDescriptors (/usr/local/lib/node_modules/@babel/core/lib/config/config-descriptors.js:109:29)
at createPresetDescriptors (/usr/local/lib/node_modules/@babel/core/lib/config/config-descriptors.js:101:10)
at presets (/usr/local/lib/node_modules/@babel/core/lib/config/config-descriptors.js:47:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @project@1.0.0 lint: `vue-cli-service lint`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @project@1.0.0 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-04-14T18_59_23_427Z-debug.log
ERROR: Job failed: command terminated with exit code 1
Run Code Online (Sandbox Code Playgroud)
eslint获得在构建的映像中提供工作所需的依赖项而不必每次都安装依赖项的最佳方法是什么?我不想依赖于安装devDependencies项目,因为由于不相关的依赖项被修补等原因,仍然经常会出现缓存失效。
| 归档时间: |
|
| 查看次数: |
1582 次 |
| 最近记录: |