How to specify node version with circleci/php:5.6.31-cli-node-browsers?


If I’m using circleci/php:5.6.31-cli-node-browsers, how can I know/lock the version of node that’s being used?

The problem I am trying to avoid is dealing with node-sass. If the version of node is updated but my package.json file hasn’t changed, then the cache won’t be rebuilt and my build will fail. I can’t add the version of node to my key name because I’m setting the key as a reference variable and node isn’t available at that time because the references are created before the container is used.

I can manually rebuild node-sass every time I restore the node_modules folder, but that is unnecessary the majority of the time and error prone. I can also manually update the key using a version prefix to the key names, but again it’s one of those things that would need to be done after a build has failed.

  container_config: &container_config
    working_directory: ~/container
      - image: circleci/php:5.6.31-cli-node-browsers

  webroot_npm_cache_key: &webroot_npm_cache_key
    v1-webroot-npm-cache-{{ checksum "./app/webroot/package.json" }}

  restore_webroot_node_modules: &restore_webroot_node_modules
        - *webroot_npm_cache_key

    <<: *container_config
      - *restore_webroot_node_modules
      - run:
          name: 'Rebuild node-sass'
          # Rebuild node-sass in case node version has changed
          command: npm rebuild node-sass

Nodejs version

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.