que nodejs node instalar elastic ec2 dynamodb aws app javascript node.js amazon-web-services webpack elastic-beanstalk

javascript - nodejs - AWS Elastic Beanstalk: cómo compilar el paquete JS utilizando npm y paquete web



node js server on amazon ec2 (3)

Tengo una aplicación node js desplegada en elasticbeanstalk. Nodo, npm y webpack instalados y enlazados. Pero cuando ejecuta npm run build-prod que llama al script webpack --config /var/app/current/webpack.prod.config.js . Obteniendo el siguiente error con el estado de salida -2. Lo mismo ocurre si también ejecuto el comando webpack directamente. Estoy buscando soluciones.

[2016-07-26T06:57:36.301Z] INFO [9731] - [Application update app-5c81-160726_122417@24/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_site_web/Command 06_npm_run_build_prod] : Activity execution failed, because: > [email protected] build-prod /tmp/deployment/application > webpack --config /var/app/current/webpack.prod.config.js npm ERR! Linux 4.4.14-24.50.amzn1.x86_64 npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v4.4.6-linux-x64/bin/node" "/bin/npm" "run" "build-prod" npm ERR! node v4.4.6 npm ERR! npm v2.15.5 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] build-prod: `webpack --config /var/app/current/webpack.prod.config.js` npm ERR! spawn sh ENOENT npm ERR! npm ERR! Failed at the [email protected] build-prod script ''webpack --config /var/app/current/webpack.prod.config.js''. npm ERR! This is most likely a problem with the site-web package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! webpack --config /var/app/current/webpack.prod.config.js npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs site-web npm ERR! Or if that isn''t available, you can get their info via: npm ERR! npm ERR! npm owner ls site-web npm ERR! There is likely additional logging output above. npm ERR! Linux 4.4.14-24.50.amzn1.x86_64 npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v4.4.6-linux-x64/bin/node" "/bin/npm" "run" "build-prod" npm ERR! node v4.4.6 npm ERR! npm v2.15.5 npm ERR! code ELIFECYCLE

archivo de configuración del contenedor:

container_commands: 01_node_symlink: command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /bin/node" 02_npm_symlink: command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/npm /bin/npm" 03_npm_install_global_packages: command: "npm install webpack webpack-cli -g" 04_webpack_symlink: command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/webpack /bin/webpack" #05_webpack_run_build_prod: #command: "webpack --config /var/app/current/webpack.prod.config.js --progress --colors" 06_npm_run_build_prod: command: "npm run build-prod"

Scripts en package.json

"scripts": { "build": "webpack --config webpack.local.config.js --progress --colors", "build-local": "webpack --config webpack.prod.config.js --progress --colors", "build-prod": "webpack --config /var/app/current/webpack.prod.config.js", "server": "node app.js", "dev-server": "node dev-app.js" }

Y cuando descomente 05 que se ejecute directamente el comando webpack, termina con el error Error: "/var/app/current/site-web/static/assets/app/index.js" is not in the SourceMap.

El script de compilación tiene éxito en local, pero está bloqueado en todas las formas de producción. No se pudo encontrar la forma de ejecutar el comando de paquete web para construir JS en AWS Beanstalk Environment. ¿No es la forma ideal de compilar el archivo JS?

nodo: 4.4.6 npm: 2.15.5 paquete web: más reciente


Finalmente, logré ejecutar el script de compilación en el dir de ensayo. No es una solución permanente, pero funciona.

05_webpack_run_build_prod: command: "cd /tmp/deployment/application && sudo webpack --config webpack.prod.config.js --progress --colors"


Todavía soy nuevo en beanstalk elástico y tengo problemas similares a mí mismo, pero me di cuenta de que sus tareas para symlinking node, npm, etc., están en la forma de container_commands .

Según los documentos oficiales , "se ejecutan después de que la aplicación y el servidor web se hayan configurado y se haya extraído el archivo de la versión de la aplicación, pero antes de que se implemente la versión de la aplicación".

Tal vez intente usar commands: lugar de container_commands: Ver el enlace que compartí.

¿Quizás el hecho de que estos comandos no se estén ejecutando hasta después de que la aplicación y el servidor web ya hayan sido configurados es por qué puede no funcionar para usted?

Una vez más, todavía soy nuevo en Beanstalk elástico, pero tal vez eso pueda ayudar.


Tuve problemas con las instalaciones globales de npm (en mi caso, react-scripts). Lo que hice como solución fue instalar el paquete dependiente como declarado en package.json y luego /tmp/deployment/application/node_modules/.bin simbólicamente (ubicado en /tmp/deployment/application/node_modules/.bin en EC2) en el archivo de configuración .ebextensions :

03_react_scripts_symlink: command: "ln -sf /tmp/deployment/application/node_modules/.bin/react-scripts /bin/react-scripts" 04_npm_run_build_prod: command: "sudo npm run build"