Bitbucket管道运行npm失败

bas*_*abi 5 linux bash bitbucket node.js bitbucket-pipelines

我为我的Bitbucket管道配置了一个PHP映像,该映像通过YML文件运行脚本。我有一个laravel存储库,想要执行构建命令。

尽管问题出在我的脚本上,但运行npm install时失败。

bash: npm: command not found

# This is a sample build configuration for PHP.
# Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: php:7.1.1

pipelines:
  default:
    - step:
        caches:
          - composer
        script:
          - apt-get update && apt-get install -y unzip
          - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
          - composer install
          - npm install --global gulp-cli
          - npm install
          - gulp --production
Run Code Online (Sandbox Code Playgroud)

maz*_*dlx 5

这应该有所帮助。它将安装Node v8和NPM v5。放在前面npm install --global gulp-cli

script:
    - curl -sL https://deb.nodesource.com/setup_8.x | bash -
    - apt-get install -y nodejs
Run Code Online (Sandbox Code Playgroud)


nma*_*anh 5

你的问题在这里:

您正在使用

图像:php:7.1.1 泊坞窗图像。

其中不包含 nodejs 和 npm。正如您在 Dockerfile 中看到的:

https://github.com/docker-library/php/blob/eadc27f12cfec58e270f8e37cd1b4ae9abcbb4eb/7.1/Dockerfile

您有多种方法可以解决您的问题。

任何一个:

  • 使用@mazedlx 提到的包管理器安装依赖项

  • 使用另一个包含 npm 和 nodejs 的 dockerimage,如下所示:https ://hub.docker.com/r/_/node/

    • image: php:7.1.1随fe变化image: node:latest