System specification -
node version - v10.15.0
npm version - 6.4.1
aws-cli version - aws-cli/1.16.81 Python/3.6.0 Windows/10 botocore/1.12.71
sam-cli version - SAM CLI, version 0.41.0
Running on a windows machine.
So I have a node project, which would be deployed to aws-sam. I have scripts for sam-validate, prepare, package. But when I run this script via npm run <package-name>, commands don't run. For example If I run npm run package, I get the following -
aws --region <region-name> s3api head-bucket --bucket <bucket-name>
Command not run
Command executed in 0 msec
aws --region <<region-name>> cloudformation package --template-file template.yaml --s3-bucket <bucket-name> --output-template-file template-deploy.yaml
Command not run
Command executed in 0 msec
But surprisingly If I run those commands from powershell individually, then it works fine. Which made me come to the realization that scripts are okay, as the generated commands do work when I run them individually.
I checked my environment variables. All the things(node path, aws cli path etc.) are there.
What am I missing here? Simply put the problem is - Do I need to do anything else to run aws-cli or sam-cli commands through node scripts?
There might be an issue with your scripts i think,
Consider writing the script in python like
import subprocesses
commandToBeExecutedOnShell='any command'
subprocess.check_call(commandToBeExecutedOnShell, shell=True)
You can then either run the scripts from python itself or
create a separate node app which calls python functions
Reference This
and then run that node app using npm run
Related
I have followed the following Medium post on How to Configure postman / newman API tests in Azure DevOps or TFS and Publish HTML Results?
In my pipeline I have a task to install newman (Pass with command install newman -g) and a task to run api tests.(Fail - Error: 'newman' is not recognized as an internal or external command.)
I have tried: A few solutions that can be found here and here .
In my Environment variables I have:
npm\node_modules\newman\bin
\npm\node_modules\newman
%AppData%\npm
I did install newman using npm install -g newman and if I run newman -v I get a result of 5.2.2.
My Azure task to run API request: newman run Auth.postman_collection.json -e UserAuthEnvironmentVariables.postman_environment.json --reporters cli,junit --reporter-junit-export Results\junitReport.xml
'C:\Users<user>\AppData\Roaming\npm' contains 3 newman files and C:\Users\RRQA.RRIOMQAS01\AppData\Roaming\npm\node_modules\newman also contains files and folders.
My node version is v14.16.1 and npm version is 6.14.12
When I edit environment variables I do restart my the server to make sure changes did take affect.
Any other suggestions what I might try to figure out the issue.?
When you are running command line from azure and when you locally login to the system it might be running under different user identities (one in admin and another in your account) so sometimes what ever you have installed or set in environment variable won't be available in the admin identity login.
Make sure the installation is done for all users. (Add path to system variable ) else:
install it as local module in the project directory as :
npm install newman newman-reporter-htmlextra
and use :
"./node_modules/.bin/newman" run
We installed NPM and created an AMI
The elastic beanstalk uses that AMI to create an EC2
The Procfile calls a shell script with the content pasted below.
I am getting the error - npm : command not found (when i use the command npm manually, it works, only fails during beanstalk deploy)
Also used the full path for npm(home/ec2-user/.nvm/versions/node/v11.6.0/bin/npm), which results in permission denied
I know its just a minor thing I am missing here, already spent few hours on this.
I tried sourcing my bash profile, which also results in permission denied.
#!/usr/bin/env bash
npm install
npm install -g serve
npm run build
nohup serve -s build > orgweb.log &
Not sure if it is just a typo or did you use this exact full path
home/ec2-user/.nvm/versions/node/v11.6.0/bin/npm
But if you did, there needs to be a slash before home, as in
/home/ec2-user/.nvm/versions/node/v11.6.0/bin/npm
I am new to docker and I ran these two commands in my mac terminal
docker pull amazonlinux
docker run -v $(pwd):/lambda-project -it amazonlinux
After running these two commands, I entered into the Linux terminal, where I installed Nodejs and few node modules
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
. ~/.nvm/nvm.sh
nvm install 6.11.5
npm -v
npm install serverless -global
everything worked fine so far, I was able to run npm -v and it showed me npm version and also serverless -v worked fine.
Then I did exit and I came out of the container into my local terminal.
Then I entered into my container again by using below command
docker run -v $(pwd):/lambda-project -it amazonlinux
This time my installations are gone. npm -v gave me the command not found.
My question is that how can I save the state or modules installed into a container and how can I log in again into the container to work further after exiting from the container.
With each docker run command you are starting another new container. You can run the command docker ps --all. You will see all containers (including exited ones) and their IDs. You can restart an exited container with the command docker restart <id>. The container is now running. With the command docker attach <id> you are back in the container. All installed libraries should still be present, but:
The downloaded shell script sets some shell variables. After attaching to the container, you can run the shell script again: . ~/.nvm/nvm.sh. Now you can access npm. This shell command prints out what it did and what you should do to keep those changes.
If you want to keep all those changes and use it regularly you can write a Dockerfile which builds an image with all those libs already installed. This official page gets you started in writing Dockerfiles: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
I'm trying to push my React App build to an S3 bucket from Jenkins/BlueOcean plugin.
But the aws command doesn't work inside of the Jenkins script.
This is what my script is doing:
#!/usr/bin/env sh
set -x
npm install -g aws-sdk
set +x
set -x
aws
echo $PATH
set +x
Here's the output:
The npm install works just fine, even npm start (to start my react server on localhost). In my development environment I can type aws without any errors.
I'm guessing it's an issue with the PATH? I've only been able to find issues regarding npm not working, but that works fine for me.
Why can't the script find aws as a command? How do I fix that?
I am running CentOS Linux release 7.1.1503 (Core) and I frequently run into a problem of missing node modules.
Here are some paths I printed on the console:
which npm
/root/.nvm/versions/node/v8.2.1/bin/npm
which node
/root/.nvm/versions/node/v8.2.1/bin/node
which forever
/usr/local/bin/forever
Now, when I start the script with forever it runs. Sometimes in the midnight, when I just verify if all the scripts are running, many are failing and the error is something like:
I have to go and install the node module. What could possibly be the reason for this? Could it be some permission issue?
Check if you have fs-extra installed at the directory you working or globally (if not - just run npm install fs-extra)
If you are going to work with AWS.S3 - check credentials permissions (for example aws s3 ls - you should see list of available buckets)