Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Error in pipeline: Error: Error: Cannot find module 'jsforce'

rbehera April 8, 2022

Our pipeline is throwing errors at a certain step. But running the same command in local works. Not sure what is happening. Any help is deeply appreciated.

 

Pipeline output:

+ npm run test
> makehttprequest@1.0.0 test /opt/atlassian/pipelines/agent/build/lambda_functions/makeHttpRequest
> npx cross-env NODE_ENV=dev nyc --reporter=html --reporter=text mocha --timeout 15000 --exit
npx: installed 7 in 1.561s
....
39 passing (2s)
11 pending
2 failing
1) makeHttpRequest
makeHttpRequest HTTP Post Learner:
Error: Error: Cannot find module 'jsforce'
at Object.exports.handler (index.js:3:1129)
at process._tickCallback (internal/process/next_tick.js:68:7)
2) makeHttpRequest
makeHttpRequest HTTP Get Learner response:
Error: Error: Cannot find module 'jsforce'
at Object.exports.handler (index.js:3:1129)
at process._tickCallback (internal/process/next_tick.js:68:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! makehttprequest@1.0.0 test: `npx cross-env NODE_ENV=dev nyc --reporter=html --reporter=text mocha --timeout 15000 --exit`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the makehttprequest@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-04-08T13_46_10_145Z-debug.log
Package.json:
{
        "dependencies": {
                "node-fetch": "^2.6.0",
                "jsforce": "^1.10.1"
          }
}
bitbucket-pipelines.yml:
        - step:
            name: 'makeHttpRequest'
            caches:
              - node
            condition:
              changesets:
                includePaths:
                  - 'lambda_functions/makeHttpRequest/**'
            script:
              - cat env.sh
              - source env.sh
              - cd ./lambda_functions/makeHttpRequest
              - npm i
              - npm run test
              - npm un -D
              - apt-get update && apt-get install -y zip
              - zip -r lambda_bundle.zip ./ -x *.json -x *.git* -x *.history* -x /coverage/* -x /logs/* -x /.nyc_output/* -x /.vscode/* -x /test/*
              - pipe: atlassian/aws-lambda-deploy:0.2.1
                variables:
                  AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
                  AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
                  AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}
                  FUNCTION_NAME: 'makeHttpRequest'
                  COMMAND: 'update'
                  ZIP_FILE: 'lambda_bundle.zip'
              - source pipe.meta.env
              - pipe: atlassian/aws-lambda-deploy:0.2.1
                variables:
                  AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
                  AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
                  AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}
                  FUNCTION_NAME: 'makeHttpRequest'
                  COMMAND: 'alias'
                  ALIAS: $ENV
                  VERSION: '${function_version}'
                  DESCRIPTION: $ENV-$(date +%Y-%m-%d)

1 answer

0 votes
lissyaka April 11, 2022

Hi @rbehera .

Please check that your package.json with `jsforce` in the folder  `/lambda_functions/makeHttpRequest`

When you do `npm i` npm tries to find package.json in the folder where you are.
Previously you did `cd ./lambda_functions/makeHttpRequest`
Maybe this is the problem.

Cheers.

rbehera April 18, 2022

@lissyaka Thanks! I did check it's there in `package.json` in dependencies.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events