Install npm package globally on AWS Elastic Beanstalk - node.js

I'm trying to install an npm package globally on elastic beanstalk. This is what my config file looks like which I wrote based on this documentation.
container_commands:
install_phantom:
command: "npm install phantomjs -g"
And when I deploy to Elastic Beanstalk I get this error
Command failed on instance. Return code: 1 Output: Error occurred
during build: Command install_phantom failed .

Based on the answer given here, have you tried:
container_commands:
install_phantom:
command: "export PATH=$PATH; npm install phantomjs -g"

The environment variable for the node installation is NODE_HOME, so you should do this, to run npm or node in a container command in your config files:
container_commands:
install_phantom:
command: bash -c "PATH=$PATH:$NODE_HOME/bin npm install phantomjs -g"

Related

Yarn command "develop" not found

For reference, the goal is to design a blog website on github using .mdx format.
I'm trying to run a prebuilt docker container (I did not compose the image) using an M1 Mac. For ambiguity's sake - let's say the container image is called "docker run -it -p "8881:8000" -v "$PWD:/app" "xxxxxxxx/yyy-zzz-purpose-of-container". One of the container dependencies is yarn, as can be seen from the output. Also, the yarn command "develop" is erroring as not found. Aside from the seemingly inocuous license output, the CLI displays:
warning package.json: No license field error Command "develop" not found.
I then tried to run it natively without the docker image as a node.js sequence of commands, and received the same error.
nvm install --lts="Gallium"
nvm alias default 'lts/Gallium'
npm install -g npm
npm install -g gatsby-cli
npm install -g yarn
yarn install .
yarn run develop
I get the same error as with the container.

Local Npm module "jshint-stylish" not found. Is it installed?

Hi I am building docker image from node js project.
docker files contents are like below
fetch code from git repo.
install npm
install grunt cli
grunt build
please see below docker file
FROM ubuntu:latest
# Install Node.js and npm
RUN apt-get -y update
RUN apt-get -y install nodejs npm git wget curl
RUN git config --global http.sslverify false
WORKDIR /somerepo/
RUN git clone -somerepo
WORKDIR /somerepo/src/
RUN npm cache clean -f
RUN npm install -g n
RUN n stable
RUN npm install
RUN npm install -g grunt-cli
RUN grunt build
EXPOSE 3000
CMD ["node", "web.js"]
but its grunt build step is failing below error in logs
Step 14/15 : RUN grunt build
---> Running in d0f8863081f1
Local Npm module "jshint-stylish" not found. Is it installed?
Running "clean:dist" (clean) task
...
...
...
Running "githooks:all" (githooks) task
Binding jsbeautifier:pregit to pre-commit Git hook.
OK
Running "jshint:dev" (jshint) task
Warning: The "path" argument must be of type string. Received type object Use --force to continue.
Do any have any idea why grunt build is not ending successufully ?
I have already tried --save-dev option and also tried manually installing jshint with below command
#RUN npm install --save-dev jshint-stylish
Also i tried to print the files/directories having pattern "jshint" with below command in dockerfile
RUN find . -name "*jshint*"
and its printing below output in logs
Step 13/15 : RUN find . -name "*jshint*"
---> Running in db355c19f75a
./node_modules/.bin/jshint
./node_modules/ascii-table/.jshintrc
./node_modules/bl/.jshintrc
./node_modules/errno/.jshintrc
./node_modules/escodegen/.jshintrc
./node_modules/estraverse/.jshintrc
./node_modules/exit/.jshintrc
./node_modules/findup-sync/.jshintrc
./node_modules/gaze/.jshintrc
./node_modules/getobject/.jshintrc
./node_modules/globule/.jshintrc
./node_modules/grunt-contrib-clean/.jshintrc
./node_modules/grunt-contrib-compress/.jshintrc
./node_modules/grunt-contrib-concat/.jshintrc
./node_modules/grunt-contrib-cssmin/.jshintrc
./node_modules/grunt-contrib-jshint
./node_modules/grunt-contrib-jshint/tasks/jshint.js
./node_modules/grunt-contrib-jshint/tasks/lib/jshint.js
./node_modules/grunt-contrib-uglify/.jshintrc
./node_modules/grunt-contrib-watch/.jshintrc
./node_modules/grunt-express-server/.jshintrc
./node_modules/grunt-git-describe/.jshintrc
./node_modules/grunt-githooks/.jshintrc
./node_modules/grunt-img/node_modules/.bin/jshint
./node_modules/grunt-img/node_modules/grunt-contrib-jshint
./node_modules/grunt-img/node_modules/grunt-contrib-jshint/.jshintrc
./node_modules/grunt-img/node_modules/grunt-contrib-jshint/docs/jshint-examples.md
./node_modules/grunt-img/node_modules/grunt-contrib-jshint/docs/jshint-options.md
./node_modules/grunt-img/node_modules/grunt-contrib-jshint/docs/jshint-overview.md
./node_modules/grunt-img/node_modules/grunt-contrib-jshint/tasks/jshint.js
./node_modules/grunt-img/node_modules/grunt-contrib-jshint/tasks/lib/jshint.js
./node_modules/grunt-img/node_modules/grunt-contrib-jshint/test/jshint_test.js
./node_modules/grunt-img/node_modules/jshint
./node_modules/grunt-img/node_modules/jshint/packages/jshint
./node_modules/grunt-img/node_modules/jshint/packages/jshint/jshint.js
./node_modules/grunt-jsbeautifier/.jshintrc
./node_modules/grunt-json-replace/.jshintrc
./node_modules/grunt-legacy-log/.jshintrc
./node_modules/grunt-legacy-log-utils/.jshintrc
./node_modules/grunt-legacy-util/.jshintrc
./node_modules/grunt-lib-contrib/.jshintrc
./node_modules/grunt-manifest/.jshintrc
./node_modules/grunt-prettify/.jshintrc
./node_modules/grunt-sloc/.jshintrc
./node_modules/grunt-sloccount/.jshintrc
./node_modules/grunt-text-replace/.jshintrc
./node_modules/handlebars/.jshintrc
./node_modules/ibrik/node_modules/estraverse/.jshintrc
./node_modules/isstream/.jshintrc
./node_modules/istanbul/node_modules/estraverse/.jshintrc
./node_modules/jshint
./node_modules/jshint/bin/jshint
./node_modules/jshint/src/jshint.js
./node_modules/jshint-stylish
./node_modules/keep-alive-agent/.jshintrc
./node_modules/less/.idea/jsLinters/jshint.xml
./node_modules/less/.jshintrc
./node_modules/log4js/.jshintrc
./node_modules/nodemon/.jshintrc
./node_modules/phantomjs/.jshintrc
./node_modules/promise/.jshintrc
./node_modules/prr/.jshintrc
./node_modules/request-progress/.jshintrc
./node_modules/resolve-url/.jshintrc
./node_modules/restify/node_modules/qs/.jshintignore
./node_modules/restify/node_modules/qs/.jshintrc
./node_modules/save/.jshintignore
./node_modules/save/.jshintrc
./node_modules/shelljs/jshint.json
./node_modules/source-map-resolve/.jshintrc
./node_modules/source-map-url/.jshintrc
./node_modules/undefsafe/.jshintrc
./node_modules/urix/.jshintrc
./node_modules/xtend/.jshintrc
if anyone have any idea what is wrong please let me know
Thanks in advance !!!

Elastic Beanstalk + Laravel: Can't run Gulp because of old NodeJS Version 0.10

I try to deploy a Laravel repo on AWS Elastic Beanstalk. For this I've created a PHP environment on a t2.medium instance and initialized a deployment with AWS CodePipeline.
I need to run npm and gulp on production for creating my static assets, but unfortunately I'm not able to run NPM because of an old NodeJS version installed. It's 0.10.46-1nodesource.el7.centos.
At the moment I'm using two config scripts to install NodeJS 10.X, run the migrations and gulp:
First:
commands:
01getNodeRepo:
command: "curl --silent --location https://rpm.nodesource.com/setup_10.x | bash -"
02installNode:
command: "yum install -y nodejs"
03updateNpm:
command: "npm install npm -g"
04enableSudo:
command: "echo Defaults:root \\!requiretty >> /etc/sudoers"
Second:
container_commands:
01artisanMigrate:
command: "php artisan migrate --force"
02showNodeVersion:
command: "node -v"
03showNpmVersion:
command: "npm -v"
04npmInstall:
command: "sudo npm install"
05gulp:
command: "sudo ./node_modules/.bin/gulp --production"
Here is an extract from my log files which shows that AWS EB found two nodesource repos and will be using the old version:
[2019-01-01T19:32:23.008Z] INFO [1535] - [Application update code-pipeline-xx-xxx#17/AppDeployStage0/EbExtensionPreBuild/Infra-EmbeddedPreBuild/xxxx/Command 02installNode] : Starting activity...
[2019-01-01T19:32:25.314Z] INFO [1535] - [Application update code-pipeline-xx-xxx#17/AppDeployStage0/EbExtensionPreBuild/Infra-EmbeddedPreBuild/xxxx/Command 02installNode] : Completed activity. Result:
Loaded plugins: priorities, update-motd, upgrade-helper
Repository nodesource is listed more than once in the configuration
Repository nodesource-source is listed more than once in the configuration
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 0:0.10.46-1nodesource.el7.centos will be installed
--> Finished Dependency Resolution
Any ideas how I can force the environment to use the new version? Thanks!
Got it. This was the solution: https://github.com/nodesource/distributions/issues/421#issuecomment-318560799
rm -f /etc/yum.repos.d/nodesource-el.repo
yum clean all
yum -y remove nodejs
yum -y install nodejs

docker npm install serve fails

I'm not very familiar to docker, but I'm trying to put the frontend (written with create-react-app) into the docker container.
I've found a tutorial and followed it, so my Dockerfile looks like this:
FROM node:7.8.0
ENV NPM_CONFIG_LOGLEVEL warn
RUN npm install -g serve
CMD serve -s --port 8081 build
EXPOSE 8081
COPY package.json package.json
COPY npm-shrinkwrap.json npm-shrinkwrap.json
RUN npm install
COPY . .
RUN npm run build --production
In my machine it works ok, but when I try to put it on server (raspberry pi) with docker-compose it fails.
Step 3 : RUN npm install -g serve
ERROR: Service 'frontend' failed to build: rpc error: code = 2 desc = "oci runtime error: exec format error"
I've googled, but haven't found exactly this problem. I even tried to put sudo before npm install, but got an error
/bin/sh: 1: sudo: not found
You can either create your private repository locally or can push it to docker-hub and then try loading it on raspberry-pi.

Installing global node packages over Amazon Elastic Beanstalk (EBS)

I have a node application deployed over amazon EBS and it was working fine till I wrote a gulp task to be executed before deploying the application. now this gulp task needs gulp to be installed globally on server.
I wrote container command in EBS config file to install gulp globally but I get following error while deploying the application,
Command npm (npm install -g gulp) failed
My config file looks something like this:
packages:
yum:
libcurl: []
libcurl-devel: []
container_commands:
npm:
command: "npm install -g gulp"
updatefunders:
command: "./update_data.sh"
I am kind of stuck with this and this issue is preventing us from deploying gulp related updates to EBS. Any help would be greatly appreciated.

Resources