Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jeffwray's avatar

Trying to deploy Spark to AWS Elastic Beanstalk... Having issues...

Hi,

I am trying to deploy Spark application to ElasticBeanstalk... Having some issues...

I am able to install Node but cant seem to get npm run production to work properly:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'production' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'preproduction', 'production', 'postproduction' ]
5 info lifecycle @~preproduction: @
6 silly lifecycle @~preproduction: no script for preproduction, continuing
7 info lifecycle @~production: @
8 verbose lifecycle @~production: unsafe-perm in lifecycle true
9 verbose lifecycle @~production: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/var/app/ondeck/node_modules/.bin:/usr/bin
10 verbose lifecycle @~production: CWD: /var/app/ondeck
11 silly lifecycle @~production: Args: [ '-c',
11 silly lifecycle   'cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js' ]
12 info lifecycle @~production: Failed to exec production script
13 verbose stack Error: @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
13 verbose stack spawn sh ENOENT
13 verbose stack     at exports._errnoException (util.js:1020:11)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:197:32)
13 verbose stack     at onErrorNT (internal/child_process.js:376:16)
13 verbose stack     at _combinedTickCallback (internal/process/next_tick.js:80:11)
13 verbose stack     at process._tickCallback (internal/process/next_tick.js:104:9)
14 verbose pkgid @
15 verbose cwd /var/app/ondeck
16 error Linux 4.9.32-15.41.amzn1.x86_64
17 error argv "/usr/bin/node" "/usr/bin/npm" "run" "production"
18 error node v6.12.0
19 error npm  v3.10.10
20 error file sh
21 error path sh
22 error code ELIFECYCLE
23 error errno ENOENT
24 error syscall spawn sh
25 error @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
25 error spawn sh ENOENT
26 error Failed at the @ production script 'cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
26 error Make sure you have the latest version of node.js and npm installed.
26 error If you do, this is most likely a problem with the  package,
26 error not with npm itself.
26 error Tell the author that this fails on your system:
26 error     cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
26 error You can get information on how to open an issue for this project with:
26 error     npm bugs
26 error Or if that isn't available, you can get their info via:
26 error     npm owner ls
26 error There is likely additional logging output above.
27 verbose exit [ 1, true ]
0 likes
3 replies
ejdelmonico's avatar

Looks like the npm install was not completed before trying to run a task.

jeffwray's avatar

Ok, I separated the install command out as a separate command and now get a different error.

Configuration

# these commands run before the application and web server are
# set up and the application version file is extracted
commands:
  01_mznode_install:
    # run this command from /tmp directory
    cwd: /tmp
    # don't run the command if node is already installed (file /usr/bin/node exists)
    test: '[ ! -f /usr/bin/node ] && echo "node not installed"'
    # install from epel repository
    # flag -y for no-interaction installation
    command: 'curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash - && yum install nodejs -y'
  02_mzyarn_install:
    # run this command from /tmp directory
    cwd: /tmp
    # don't run the command if yarn is already installed (file /usr/bin/yarn exists)
    test: '[ ! -f /usr/bin/yarn ] && echo "yarn not installed"'
    # install from epel repository
    # flag -y for no-interaction installation
    command: 'sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo && yum install yarn -y'
container_commands:
   01_permission:
      command: sudo chmod -R 777 /var/app/ondeck/storage/logs
   05_npm_build_prod:
      command: cd /var/app/ondeck && rm -rf node_modules && npm install
   06_npm_run_production:
      command: npm config set scripts-prepend-node-path true && npm run production

Error Log:

[2017-11-30T21:54:14.187Z] INFO  [11984] - [Application update newloyaltyappweb-eeb0b139-33d4dc@118/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_Get_Perked_Web/Command 05_npm_build_prod] : Starting activity...
[2017-11-30T21:57:30.901Z] INFO  [11984] - [Application update newloyaltyappweb-eeb0b139-33d4dc@118/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_Get_Perked_Web/Command 05_npm_build_prod] : Activity execution failed, because: npm WARN deprecated [email protected]: express 2.x series is deprecated
  npm WARN deprecated [email protected]: connect 1.x series is deprecated
  npm WARN lifecycle npm is using /usr/bin/node but there is no node binary in the current PATH. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
  
  > [email protected] install /var/app/ondeck/node_modules/node-sass
  > node scripts/install.js
  
  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
  npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
  
  npm ERR! file sh
  npm ERR! path sh
  npm ERR! code ELIFECYCLE
  npm ERR! errno ENOENT
  npm ERR! syscall spawn sh
  npm ERR! [email protected] install: `node scripts/install.js`
  npm ERR! spawn sh ENOENT
  npm ERR!
  npm ERR! Failed at the [email protected] 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!     /root/.npm/_logs/2017-11-30T21_57_30_683Z-debug.log
   (ElasticBeanstalk::ExternalInvocationError)
hellomars's avatar

I installed Spark on AWS BeanStalk by just zipping the complete running folder on my dev machine (including vendor folder) and uploading it. I will probably use the same IAM for standard EC2 instances.

Please or to participate in this conversation.