简体   繁体   English

我是否必须在需要使用 npm 命令的 bitbucket 管道中的每一步都进行 npm install

[英]Do I have to npm install in every step in a bitbucket pipeline that I need to use an npm command

I have a bitbucket pipelines yml that I have step for running my test script and a step to run a serverless deploy script.我有一个 bitbucket 管道 yml,我有运行测试脚本的步骤和运行无服务器部署脚本的步骤。 Do I need to npm install at each step or will the first npm install carry through and suffice for each subsequent step.我是否需要在每一步进行 npm install 或者第一个 npm install 是否会继续执行并足以满足后续的每个步骤。 Further than that, what is happening under the hood?除此之外,引擎盖下发生了什么? I know Docker container is created;我知道 Docker 容器已创建; does each step just update the container?每一步都只是更新容器吗?

- step:
        name: Test and Build
        script: 
          - npm install --no-package-lock
          - npm run test
    - step:
        name: Deploy Serverless
        script:
          - npm i serverless -g
          - npm install --no-package-lock
          - npm run deploy

Can you implement it like the documentation: https://confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html你能像文档一样实现它: https : //confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html

The functionality is there.功能就在那里。 Let me know if it doesn't work for you still.如果它仍然对您不起作用,请告诉我。

Each step in the pipe creates a separate docker container which pulls in your branch.管道中的每一步都会创建一个单独的 docker 容器,用于拉入您的分支。 Using the cache option will allow your pipe to skip the install when building the container for the second step by pulling node_modules from the cache.使用缓存选项将允许您的管道在通过从缓存中提取 node_modules 为第二步构建容器时跳过安装。 You must still include the npm install line in each step to tell the pipe to use the cache if it exists.您仍然必须在每个步骤中包含npm install行,以告诉管道使用缓存(如果存在)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM