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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

"Error: Cannot find module '../'" when deploying to NodeJS environment on Elastic Beanstalk

Recently I have been unable to deploy to my Elastic Beanstalk environment. The error is due to a node package. The node package in question is not in my package.json as its dependency of another package. I believe the issue is to do with how Bitbucket Pipelines installs the package as I can successfully zip up my local directory and deploy manually and it works fine.

Here is the error output:

 

[2020-06-17T12:51:50.566Z] ERROR [30079] : Command execution failed: Activity failed. (ElasticBeanstalk::ActivityFatalError)
caused by: + /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install
  removed 1 package and audited 707 packages in 4.958s
  found 13 vulnerabilities (2 low, 6 moderate, 5 high)
    run `npm audit fix` to fix them, or `npm audit` for details
 
  > core-js@2.6.11 postinstall /tmp/deployment/application/node_modules/core-js
  > node -e "try{require('./postinstall')}catch(e){}"
 
  [96mThank you for using core-js ( [94m https://github.com/zloirock/core-js [96m) for polyfilling JavaScript standard library! [0m
 
  [96mThe project needs your help! Please consider supporting of core-js on Open Collective or Patreon: [0m
  [96m> [94m https://opencollective.com/core-js [0m
  [96m> [94m https://www.patreon.com/zloirock [0m
 
  [96mAlso, the author of core-js ( [94m https://github.com/zloirock [96m) is looking for a good job -) [0m
 
 
  > protobufjs@6.9.0 postinstall /tmp/deployment/application/node_modules/protobufjs
  > node scripts/postinstall
 
 
  > grpc@1.24.3 install /tmp/deployment/application/node_modules/grpc
  > node-pre-gyp install --fallback-to-build --library=static_library
 
  module.js:550
      throw err;
      ^
 
  Error: Cannot find module '../'
      at Function.Module._resolveFilename (module.js:548:15)
      at Function.Module._load (module.js:475:25)
      at Module.require (module.js:597:17)
      at require (internal/module.js:11:18)
      at Object.<anonymous> (/tmp/deployment/application/node_modules/.bin/node-pre-gyp:15:20)
      at Module._compile (module.js:653:30)
      at Object.Module._extensions..js (module.js:664:10)
      at Module.load (module.js:566:32)
      at tryModuleLoad (module.js:506:12)
      at Function.Module._load (module.js:498:3)
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! grpc@1.24.3 install: `node-pre-gyp install --fallback-to-build --library=static_library`
  npm ERR! Exit status 1
  npm ERR!
  npm ERR! Failed at the grpc@1.24.3 install 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!     /tmp/.npm/_logs/2020-06-17T12_51_50_548Z-debug.log
  Running npm install:  /opt/elasticbeanstalk/node-install/node-v8.16.2-linux-x64/bin/npm
  Setting npm config jobs to 1
  npm config jobs set to 1
  Running npm with --production flag
  Failed to run npm install. Snapshot logs for more details.
  UTC 2020/06/17 12:51:50 cannot find application npm debug log at /tmp/deployment/application/npm-debug.log
 
  Traceback (most recent call last):
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 695, in <module>
      main()
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 677, in main
      node_version_manager.run_npm_install(options.app_path)
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 136, in run_npm_install
      self.npm_install(bin_path, self.config_manager.get_container_config('app_staging_dir'))
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 180, in npm_install
      raise e
  subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v8.16.2-linux-x64/bin/npm', '--production', 'rebuild']' returned non-zero exit status 1 (ElasticBeanstalk::ExternalInvocationError)
caused by: + /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install
  removed 1 package and audited 707 packages in 4.958s
  found 13 vulnerabilities (2 low, 6 moderate, 5 high)
    run `npm audit fix` to fix them, or `npm audit` for details
 
  > core-js@2.6.11 postinstall /tmp/deployment/application/node_modules/core-js
  > node -e "try{require('./postinstall')}catch(e){}"
 
  [96mThank you for using core-js ( [94m https://github.com/zloirock/core-js [96m) for polyfilling JavaScript standard library! [0m
 
  [96mThe project needs your help! Please consider supporting of core-js on Open Collective or Patreon: [0m
  [96m> [94m https://opencollective.com/core-js [0m
  [96m> [94m https://www.patreon.com/zloirock [0m
 
  [96mAlso, the author of core-js ( [94m https://github.com/zloirock [96m) is looking for a good job -) [0m
 
 
  > protobufjs@6.9.0 postinstall /tmp/deployment/application/node_modules/protobufjs
  > node scripts/postinstall
 
 
  > grpc@1.24.3 install /tmp/deployment/application/node_modules/grpc
  > node-pre-gyp install --fallback-to-build --library=static_library
 
  module.js:550
      throw err;
      ^
 
  Error: Cannot find module '../'
      at Function.Module._resolveFilename (module.js:548:15)
      at Function.Module._load (module.js:475:25)
      at Module.require (module.js:597:17)
      at require (internal/module.js:11:18)
      at Object.<anonymous> (/tmp/deployment/application/node_modules/.bin/node-pre-gyp:15:20)
      at Module._compile (module.js:653:30)
      at Object.Module._extensions..js (module.js:664:10)
      at Module.load (module.js:566:32)
      at tryModuleLoad (module.js:506:12)
      at Function.Module._load (module.js:498:3)
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! grpc@1.24.3 install: `node-pre-gyp install --fallback-to-build --library=static_library`
  npm ERR! Exit status 1
  npm ERR!
  npm ERR! Failed at the grpc@1.24.3 install 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!     /tmp/.npm/_logs/2020-06-17T12_51_50_548Z-debug.log
  Running npm install:  /opt/elasticbeanstalk/node-install/node-v8.16.2-linux-x64/bin/npm
  Setting npm config jobs to 1
  npm config jobs set to 1
  Running npm with --production flag
  Failed to run npm install. Snapshot logs for more details.
  UTC 2020/06/17 12:51:50 cannot find application npm debug log at /tmp/deployment/application/npm-debug.log
 
  Traceback (most recent call last):
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 695, in <module>
      main()
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 677, in main
      node_version_manager.run_npm_install(options.app_path)
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 136, in run_npm_install
      self.npm_install(bin_path, self.config_manager.get_container_config('app_staging_dir'))
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 180, in npm_install
      raise e
  subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v8.16.2-linux-x64/bin/npm', '--production', 'rebuild']' returned non-zero exit status 1 (Executor::NonZeroExitStatus)


[2020-06-17T12:51:50.566Z] ERROR [30079] : Command CMD-AppDeploy failed!
[2020-06-17T12:51:50.567Z] INFO  [30079] : Command processor returning results: 

3 answers

@brianbriscoe I see you are using bitbucket-pipelines. Did not you try to use our AWS Elasticbeanstalk Deploy pipe in your pipelines? If this is issue with the pipe, please clarify what version you are using, specify the pipeline step, where you are using this pipe and we will figure out the failure.

But if it is issue with the pipeline (like I guess so), try to use elasticbeanstalk deploy pipe and I believe, it will simplify your process and avoid complex script and dependencies resolve. If this error occurs after using a pipe, we will figure out with failure.

If you don't want to use a pipe, you can show your pipeline step where you perform this script.

 

Best regards, Galyna

@Galyna Zholtkevych We are using bitbucket pipelines. WE are using the Elastic Beanstalk Pipeline version 0.5.0. Below you can find out bitbucket-pipelines.yml file. This used to work but as of about 2 weeks ago it does not work anymore. we did not change this.

 

 

image: atlassian/default-image:2

pipelines:
  branches:
    test:
      - step:
          name: "Build and deploy to test environment"
          deployment: test
          script:
            - rm -rf node_modules
            - rm package-lock.json
            - npm cache clean --force
            - npm install
            - zip -r application.zip .
            - pipe: atlassian/aws-elasticbeanstalk-deploy:0.5.0
              variables:
                AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
                AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
                AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
                APPLICATION_NAME: "app_name"
                ENVIRONMENT_NAME: 'test'
                ZIP_FILE: "application.zip"
                WAIT: 'true'
    master:
      - step:
          name: "Build and deploy to production environment"
          deployment: production
          script:
            - rm -rf node_modules
            - rm package-lock.json
            - npm cache clean --force
            - npm install
            - zip -r application.zip .
            - pipe: atlassian/aws-elasticbeanstalk-deploy:0.5.0
              variables:
                AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
                AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
                AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
                APPLICATION_NAME: "app_name"
                ENVIRONMENT_NAME: 'prod'
                ZIP_FILE: "application.zip"
                WAIT: 'true'

Looking at your YAML configuration, I would suggest to split the building and deploying part - as this will definitely help you see in which pipeline step lies the problem and allow you to store the artifact properly.

That is not related to your error (or maybe it is) but will definitely help pinpoint the real issue in the logs.

See https://support.atlassian.com/bitbucket-cloud/docs/deploy-to-aws-with-elastic-beanstalk/ and note that the pipe: atlassian/aws-elasticbeanstalk-deploy:0.5.0 is defined in a separate step with passing the artifact via artifacts keyword.

I know which step is the problem. It is the "pipe" step. This is the output

 

✖ Deployment failed. Environment "test" is running a different version "app-v2_0-763-gb3c17-200610_094118".

Screen Shot 2020-06-19 at 13.04.59.png

Like Radek Antoniuk likes this

@brianbriscoe the reason may be the application was not deployed successfully on your environment or sth else. Can you provide us with full log of aws elasticbeanstalk Pipe execution, so that we can investigate the root cause?

 

Regards, Galyna

@Galyna Zholtkevych  here is the full output. it is not descriptive and does not give the reason for error. the reason for error can be seen in my original message.

 

Screen Shot 2020-06-22 at 15.20.23.png

@brianbriscoe I suppose, the error can be that your AWS service did not update yet the environment with appropriate version and not much time has passed since update environment command was executed. It can happen if AWS is updating your environment not very fast (for instance, big or performance-consuming deployments) and just not much time has passed. You can check it during the deployment (how long the environment is being updated).

This is what I can say without knowing the actual status of your environment after this environment update.

We will investigate this issue in our environments and perhaps will update with extra version check.

But right now what I would do for your case is trying to increase WAIT_INTERVAL environment variable to 30 seconds or 60 secs depending on how long AWS updates your environment. You can know better what value you can put for this variable (approximately the time that takes to update your AWS environment, perhaps a little less, you can play with that).

By default WAIT_INTERVAL is only 10 seconds and after we compare versions ( Code reference) . See how you could update your pipe usage in the ElasticBeanstalk Pipe docs, Advanced Examples 

 

Looking forward to hearing back,

Regards, Galyna

I tried adding WAIT_INTERVAL of 300 seconds and it still failed.

Its not a timing issue as I can see on the AWS side that the failure is due to NPM install. The issue is to do with how Bitbucket Pipelines installs a specific package.

 

Are you seeing others who have this ussue?

@brianbriscoe no, we did not see others with this issue.

Sorry, I did not tied your initial failing script to the problem, so I think since the npm is failing to execute in pipeline it is worth asking bitbucket-pipeline team, for this you can create new question with `bitbucket-pipelines` tag or add this tag to the current question. 

I checked, in our npm image it does not fail, also in pipeline I am not able to reproduce it using our folders for npm install and then pipe is executed. Consider errors installing precisely your package, I see the possible root causes in

  Error: Cannot find module '../'...
  subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v8.16.2-linux-x64/bin/npm', '--production', 'rebuild']' returned non-zero exit status 1 (Executor::NonZeroExitStatus)

or with `node-pre-gyp` module (since I am not a very expert with node).

Also, we don't have subprocess calling inside this pipe, but perhaps pipelines running such commands in this way (in this case you could refer to bitbucket-pipelines team tag, as I said above).

So I suspect two possible root cause: something happened wrong in your specific script or subprocess has failed to execute command `npm --production rebuild`. If this is the last one, then it is needed to be discovered what error precisely subprocess outputs and why it failed to execute. Now I see it just failed to run the command

Also look at the version of node, it may matter. In atlassian default image we have node 8.9.4 and if another version of node fiex that, you can use the image you want with appropriate version of node

I see some bug https://github.com/grpc/grpc-node/issues/1086 where workaround was downgrading node. The same may happen with your version

@Galyna Zholtkevych ok thank you for the information. I will try these things and contact AWS about it.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Announcing the waitlist for Jira Work Management

Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...

880 views 14 20
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you