NPM is not found in script
Asked by Amit Sharma:

**Background:**

In the pipeline step, I have added multiple scripts something like

```
image: drupal:9.5.11-php8.1-fpm
pipelines:
  branches:
    test:
      - step:
          script:

            - scripts/pipelines/setup.sh
            - scripts/pipelines/validate.sh
            - scripts/pipelines/build_artifact.sh
            - scripts/pipelines/deploy_artifact.sh
          services:
            - docker
            - mysql
          caches:
            - docker
            - node
            - composer
```

I used an image where node and npm are unavailable, so I need to install the node using nvm in setup.sh. I am able to install node and npm and the commands successfully are running properly in the setup script.

I am using Acquia BLT in this pipeline. BLT command is running post code command hook where I am running one script (frontend_build.sh) to run npm install and npm run build.

**Problem:**

Inside frontend_build.sh, it is giving an error "npm command not found".

**Solution Tried:**

* I tried to update the PATH variable and source \~/.bashrc. This shows showing updated path.
* Tried to export the npm path in the custom variable but nothing works.

Suggestions are welcome.

Thanks very much for all the help.


Answers:
author: Mark C
body: Hi [@Amit Sharma](/t5/user/viewprofilepage/user-id/5337457),

Thank you for reaching out to the community.

May we know how you're installing NPM in your build?  
This is because when I tried using the base Docker image (drupal:9.5.11-php8.1-fpm), I got the same error message when running the NPM command because NPM is not available from the base Docker image.

```
+ npm --versionbash: npm: command not found
```

Regards,  
Mark C

comments: author: Amit Sharma
body: Yes [@Mark C](/t5/user/viewprofilepage/user-id/1210823) I am installing the npm in my script

```
scripts/pipelines/setup.sh
```

in the above script I am installing and setting up the path of node and npm.

Also, I have checked the version. I installed the node using nvm.


author: Mark C
body: Hi [@Amit Sharma](/t5/user/viewprofilepage/user-id/5337457)  

Thanks for that.  
Could we check if the NPM is still installed after running **setup.sh** script?  

```
          script:
            - scripts/pipelines/setup.sh
            - npm --version
            - scripts/pipelines/validate.sh
            - scripts/pipelines/build_artifact.sh
            - scripts/pipelines/deploy_artifact.sh
```

You can also try installing NPM as part of the step script instead.  

Let me know how it goes.  

Regards,  
Mark C


author: Saxea _Flowie_
body: Hi [@Amit Sharma](/t5/user/viewprofilepage/user-id/5337457)

Is frontend_build.sh running in a different step? If so, node cache only caches node_modules not the actual node install.

comments: author: Amit Sharma
body: [@Saxea _Flowie_](/t5/user/viewprofilepage/user-id/5230209) it is running inside the same step. I have added multiple scripts in the same step for reusability in other steps.


author: Amit Sharma
body: [@Saxea _Flowie_](/t5/user/viewprofilepage/user-id/5230209) I am running the Acquia BLT command in the build.sh, which runs a post-code hook. Inside this hook, I am running the frontend-build.sh

BLT picks the path of npm installed in the current container. I have used this on the local but it is not working in Pipeline.


Tags: bitbucket-cloud

bitbucket-pipelines

cloud