Install and Set Up kubectl - kubectl

I just tried to install kubectl on macos, yet got warning at the end:
$ sudo gcloud components install kubectl
Password:
Your current Cloud SDK version is: 236.0.0
Installing components from version: 236.0.0
┌─────────────────────────────────────────────────────────────────────┐
│ These components will be installed. │
├─────────────────────┬────────────────────────┬──────────────────────┤
│ Name │ Version │ Size │
├─────────────────────┼────────────────────────┼──────────────────────┤
│ kubectl │ 2018.09.17 │ < 1 MiB │
│ kubectl │ 1.10.7 │ 12.8 MiB │
└─────────────────────┴────────────────────────┴──────────────────────┘
For the latest full release notes, please visit:
https://cloud.google.com/sdk/release_notes
Do you want to continue (Y/n)? y
╔════════════════════════════════════════════════════════════╗
╠═ Creating update staging area ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: kubectl ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: kubectl ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Creating backup and activating new installation ═╣
╚════════════════════════════════════════════════════════════╝
Performing post processing steps...done.
Update done!
WARNING: There are older versions of Google Cloud Platform tools on your system PATH.
Please remove the following to avoid accidentally invoking these old tools:
/usr/local/Cellar/kubernetes-cli/1.13.2/bin/kubectl
$
I'm not sure of why there are two of kubectl (different versions) or how does one removes old tool?
Please advise.

You installed one kubectl with gcloud, and one (in the Celler directory) with brew install kubernetes-cli as described by https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-with-homebrew-on-macos
You could remove the brew-provided kubectl with brew remove kubernetes-cli like https://superuser.com/questions/273966/how-can-i-uninstall-using-homebrew

The one installed by brew maybe because of other dependencies too, for e.g.if u tried kubeless , that would have installed kubectl inside the brew directories. You could remove those or as the warning indicated, make sure the PATH doesnt include the Brew installed ones.

Related

Django/AWS EB: [app-deploy] - [RunAppDeployPreBuildHooks] error (no such file or directory), BUT the file does exist?

I have a Django application and I'm trying to deploy to my AWS EB Environment.
It's a project that my friend and I are working on.
I an trying to run the command eb deploy however though I get this:
Alert: The platform version that your environment is using isn't recommended. There's a recommended version in the same platform branch.
Creating application version archive "app-3d19-210731_133226".
Uploading Prod Rest API/app-3d19-210731_133226.zip to S3. This may take a while.
Upload Complete.
2021-07-31 17:32:29 INFO Environment update is starting.
2021-07-31 17:32:33 INFO Deploying new version to instance(s).
2021-07-31 17:32:36 ERROR Instance deployment failed. For details, see 'eb-engine.log'.
2021-07-31 17:32:39 ERROR [Instance: i-05761282d68083a51] Command failed on instance. Return code: 1 Output: Engine execution has encountered an error..
2021-07-31 17:32:39 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2021-07-31 17:32:39 ERROR Unsuccessful command execution on instance id(s) 'i-05761282d68083a51'. Aborting the operation.
2021-07-31 17:32:39 ERROR Failed to deploy application.
ERROR: ServiceError - Failed to deploy application.
I checked the eb-engine.og and this is what I get:
2021/07/31 17:19:47.104584 [INFO] Executing instruction: StageApplication
2021/07/31 17:19:47.111204 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
2021/07/31 17:19:47.111230 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
2021/07/31 17:19:47.154001 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ successfully
2021/07/31 17:19:47.156956 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2021/07/31 17:19:47.156982 [INFO] Executing platform hooks in .platform/hooks/prebuild/
2021/07/31 17:19:47.157046 [INFO] Following platform hooks will be executed in order: [install_supervisor.sh]
2021/07/31 17:19:47.157060 [INFO] Running platform hook: .platform/hooks/prebuild/install_supervisor.sh
2021/07/31 17:19:47.157342 [ERROR] An error occurred during execution of command [app-deploy] - [RunAppDeployPreBuildHooks]. Stop running the command. Error: Command .platform/hooks/prebuild/install_supervisor.sh failed with error fork/exec .platform/hooks/prebuild/install_supervisor.sh: no such file or directory
2021/07/31 17:19:47.157349 [INFO] Executing cleanup logic
2021/07/31 17:19:47.157565 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1627751987,"severity":"ERROR"}]}]}
2021/07/31 17:19:47.159200 [INFO] Platform Engine finished execution on command: app-deploy
I'm really confused on why this is occuring because for my friend who has the same repo, he is able to eb deploy fine but I can't for some reason.
This is my file structure:
my-app/
├─ .ebextensions/
│ ├─ 01_django.config
├─ .elasticbeanstalk/
│ ├─ config.yml
├─ .platform/
│ ├─ files/
│ │ ├─ supervisor.ini
│ ├─ hooks/
│ │ ├─ prebuild/
│ │ │ ├─ install_supervisor.sh
├─ other files/
where my other files are my actual Django code itself.
01_django.config
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: RestAPI.wsgi:application
aws:elasticbeanstalk:environment:proxy:staticfiles:
/static: static
config.yml
branch-defaults:
main:
environment: Prodrestapi-env
environment-defaults:
Prodrestapi-env:
branch: null
repository: null
global:
application_name: Prod Rest API
default_ec2_keyname: aws-eb
default_platform: Python 3.8 running on 64bit Amazon Linux 2
default_region: us-east-2
include_git_submodules: true
instance_profile: null
platform_name: null
platform_version: null
profile: eb-cli
sc: git
workspace_type: Application
supervisor.ini
# Create celery configuraiton script
[program:celeryd-worker]
; Set full path to celery program if using virtualenv
command=sh /var/app/current/scripts/worker.sh
directory=/var/app/current
; user=nobody
numprocs=1
stdout_logfile=/var/log/celery-worker.log
stderr_logfile=/var/log/celery-worker.log
autostart=true
autorestart=true
startsecs=60
; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 60
; When resorting to send SIGKILL to the program to terminate it
; send SIGKILL to its whole process group instead,
; taking care of its children as well.
killasgroup=true
; if rabbitmq is supervised, set its priority higher
; so it starts first
priority=998
install_supervisor.sh
#!/bin/sh
sudo amazon-linux-extras enable epel
sudo yum install -y epel-release
sudo yum -y update
sudo yum -y install supervisor
sudo systemctl start supervisord
sudo systemctl enable supervisord
sudo cp .platform/files/supervisor.ini /etc/supervisord.d/celery.ini
sudo supervisorctl reread
sudo supervisorctl update
I"m just really confused on why it's not deploying properly because the install_supervisor.sh file is clearly in the folder.
Any and all help will be really appreciate.
Thank you so much!

is docker-compose.yml not supported in AWS Elastic Beanstalk?

In my root directory, I have my docker-compose.yml.
$ ls
returns:
build cmd docker-compose.yml exp go.mod go.sum LICENSE media pkg README.md
In the same directory, I ran:
$ eb init -p docker infogrid
$ eb create infogridEnv
However, this gave me an error:
Instance deployment: Both 'Dockerfile' and 'Dockerrun.aws.json' are missing in your source bundle. Include at least one of them. The deployment failed.
The fact that it does not even include docker-compose.yml as the missing file makes me think it does not support docker-compose. This is contradicting with the main documentation where it explicitly shows an example with docker-compose.yml.
It may be that you use "Amazon AMI" your enviroment should be the new "Docker running on 64bit Amazon Linux 2"
only then you get the docker-compose.yml support
source https://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/docker-multicontainer-migration.html

anthoscli ERROR on installing Google Cloud SDK on Apple Silicon / Big Sur

I am searching for the solution for some weeks now. A couple weeks ago I received the new MacBook Pro with the Apple Silicon processor and with Big Sur installed on it. When I tried to install Google Cloud SDK, because I need that for my work, I get my first problem. I opened the terminal and used "curl https://sdk.cloud.google.com | bash" to start the installation.
After I received the question if I want to help to improve Google Cloud SDK and hit 'N' this error follows. Also when I hit 'Y'...
ERROR: (gcloud.components.update) The following components are unknown [anthoscli].
On the internet I can't found something about this error. The only thing what I have found on anthoscli is that I think it has something to do with Kubernetes and/or Docker. So I tried to install Docker first, only they are not ready for Apple Silicon yet...
I can't imagine being the only one with this problem so I hope someone here can help me further.
It's a known issue "Apple Silicon Installer does not exist"
The workaround from the above link is:
Attempt install: curl https://sdk.cloud.google.com | bash
Run installer manually using files from above failed install ./google-cloud-sdk/bin/gcloud components install core gsutil
Re-run init: ./google-cloud-sdk/bin/gcloud init
I got gcloud to install by installing under Rosetta 2.
curl https://sdk.cloud.google.com > install.sh
chmod +x install.sh
arch -x86_64 install.sh --disable-prompts
# restart shell
gcloud help
I don't think Apple did a good job of advertising this feature, because I only found it in a random Hacker News thread. I've used this strategy quite a bit and added this to my shell's rc file.
x86() {
arch -x86_64 $1
}
x86 install.sh --disable-prompts
I just tested on Apple M1 MBP Big Sur 11.1, which works for me.
Followed mager.co blogpost-How to install gcloud on an M1 Mac
Full steps as following:
Install homebrew package management first
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install Python 3.9.1 use pyenv
brew install pyenv
pyenv install 3.9.1
pyenv global 3.9.1
Set an env variable letting the gcloud installer know which version of Python to use:
export CLOUDSDK_PYTHON=python3
Download the SDK and start the install, which I ran into ERROR the following components are unknown [anthoscli, kuberun]:
curl https://sdk.cloud.google.com | bash
Thus manually run the install.sh script
cd ~/google-cloud-sdk
./install.sh --override-components core gcloud-deps bq gcloud gsutil
The easiest way to install Google Cloud SDK is with homebrew, but Homebrew doesn't have an arm64 variant for M1 yet. Nonetheless, I've outlined steps to install and use it on M1 Macs: https://stackoverflow.com/a/66299285/2006016
1. Installing gcloud SDK
After installing your Homebrew on your M1 Mac, in your Rosetta Terminal, run the following command:
brew install --cask google-cloud-sdk
2. Linking gcloud to $PATH
Once Homebrew has it installed, you'll need to add it to your path. In the last few lines it will show you the path to set your source:
From the screenshot above, I'll have to run the following to set the command in my $PATH:
source /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc
source /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc
3. Using gcloud
Once linked, you can use the gcloud command in your terminal:
gcloud -v
4. Outdated Python
In case your python is outdated (see Google Cloud SDK Requirements), you can use Homebrew to update it by running:
brew upgrade
You can view your python version when listing out your Homebrew packages:
brew outdated
This happens when you have MAC M1 chip so you might need to install manually for this i choose to go with Google given method
muhasan#Admins-MacBook-Pro ~ % curl https://sdk.cloud.google.com | bash
Output :
For the latest full release notes, please visit:
https://cloud.google.com/sdk/release_notes
╔════════════════════════════════════════════════════════════╗
╠═ Creating update staging area ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: BigQuery Command Line Tool ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: BigQuery Command Line Tool (Platform Spec... ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Storage Command Line Tool ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Storage Command Line Tool (Platform... ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Default set of gcloud commands ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Google Cloud CLI Core Libraries (Platform... ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: anthoscli ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: anthoscli ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: gcloud cli dependencies ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Creating backup and activating new installation ═╣
╚════════════════════════════════════════════════════════════╝
Performing post processing steps...done.
Update done!
Please follow the steps mentioned in the following Google Cloud SDK Installation Documentation to install Google Cloud SDK on MacOS:
Cloud SDK requires Python. Follow the next documentation on how to choose and configure your Python interpreter
Download the MacOS package from the Google Cloud SDK Documentation.
2.1) Extract the archive to any location on your file system. On macOS, this can be achieved by opening the downloaded .tar.gz archive file in the preferred location.
2.2) Optional. Use the install script to add Cloud SDK tools to your path -->
./google-cloud-sdk/install.sh
2.3) Close and Open a new terminal so that the changes take effect.
2.4) Run gcloud init to initialize the SDK:
./google-cloud-sdk/bin/gcloud init
As I can see that you have use the Google Cloud SDK Installer to install Google Cloud SDK on MacOS. Please try again the following steps to install Google Cloud SDK using the installer:
Enter the following at a command prompt:
curl https://sdk.cloud.google.com | bash
Restart your shell:
exec -l $SHELL
Run gcloud init to initialize the gcloud environment:
gcloud init
In case you want to install Google Cloud SDK through the interactive installer, and you are getting the error mentioned above, You can create an issue on Google's Public Issue Tracker for further investigation. However also please try to install the Google Cloud SDK without the installer as I mentioned before.

Installing Sharp on Elastic Beanstalk

I'm rather new to AWS. I'm running a Node.JS app on Elastic Beanstalk, and everything was working fine. However, because I need to do some image processing I decided to add Puppeteer and Sharp.
However, the installation on AWS fails and the application crashes. The log says the following:
sharp#0.21.3 install /tmp/deployment/application/node_modules/sharp
(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
ERR! sharp EACCES: permission denied, mkdir '/tmp/.npm/_libvips'
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/page/install for required dependencies
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/tmp/deployment/application/node_modules/sharp/build'
gyp ERR! System Linux 4.14.97-74.72.amzn1.x86_64
gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v10.15.1-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v10.15.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /tmp/deployment/application/node_modules/sharp
gyp ERR! node -v v10.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp#0.21.3 install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sharp#0.21.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I'm really not familiar with Elastic Beanstalk, but that seems like an access restriction error. After searching for a bit, I found a possible solution: Adding the following code as an .extension file.
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/00_set_tmp_permissions.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
chown -R nodejs:nodejs /tmp/.npm
However, that didn't seem to do anything. Does anybody know where the error could be? Or where I should look for a solution? I'm not usually at home with this kind of stuff, but I'm forced to work with it for a while. Any help and advice would be greatly appreciated!
This is permission issues with AWS.
To solve this you have to follow the next steps:
Create a new file .npmrc
Add the following unsafe-perm=true
This will let to write files.
unsafe-perm=true is not working anymore with Node 16 and Amazon Linux 2, because it can't install the Sharp package. I was trying to install Strapi v4 on Elastic Beanstalk.
You need to perform permission updates in platform hooks according to this answer: https://github.com/lovell/sharp/issues/3221#issuecomment-1126528844
You can find additonal information to platform hooks here:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html
You don't need to do anything about the execute permissions when your Amazon Linux 2 was released after April 29, 2022.
Solution:
Step 1: Create the following Platform Hooks paths in the root directory of your application bundle.
- .platform/hooks/prebuild
- .platform/confighooks/prebuild
The Platform Hook (.platform/hooks/prebuild) will execute the commands found in the bash script after the application is extracted but before the application configuration and proxy server process initiates.
The Platform Hook (.platform/confighooks/prebuild) will execute the commands found in the bash script during a configuration deployment/environment update.
Step 2: Once the above Platform Hooks paths have been created in your application bundle, the following bash script (00_npm_install.sh) will need to be created and placed under the "Prebuild" directory:
The bash script (00_npm_install.sh) will include the following:
#!/bin/bash
cd /var/app/staging
sudo -u webapp npm install sharp
Step 3: Validate the Application Bundle Structure
Sample project structure:
~/my-app/
├── app.js
├── index.html
├── .npmrc_bkp
├── package.json
├── package-lock.json
├── .platform
│ ├── confighooks
│ │ └── prebuild
│ │ └── 00_npm_install.sh
│ └── hooks
│ └── prebuild
│ └── 00_npm_install.sh
└── Procfile
Step 4: Deploy the Application!
Summary:
During the application deployment process, the application bundle is initially extracted and deployed within the /var/app/staging folder. In this same first step, all Node.js dependencies found in your (package.json) file will also be installed here but exist under /var/app/staging/node_modules/....
As mentioned in your comment, the /var/app/staging folder is owned by the webapp user but the npm install command is executed by root user. Therefore, the bash script workaround solution goes to the /var/app/staging/ directory and install the Sharp dependency by executing the sudo -u webapp npm install sharp command as the webapp user. All of this is done before the application and proxy server configuration process initiates as shown in "Instance deployment workflow".
As a result, the workaround solution will make the Elastic Beanstalk deployment process skip installing the Sharp dependency all together as it already exists! Afterwards, the application deployment process continues to the final provisioning step which moves all files/content from the /var/app/staging/ folder to the final /var/app/current/ directory location.
Lastly, the second Platform Hook (.platform/confighooks/prebuild) was implemented to avoid running into the same permissions error when performing a configuration deployment. A configuration deployment occurs when you make configuration changes that only update environment instances without recreating them!
Hope the following solution helps!

Serverless plugin "serverless-offline" not found. Make sure it's installed and listed in the "plugins" section of your serverless config file

When I deploy my SLS project, I get the following error:
Serverless plugin "serverless-offline" not found. Make sure it's
installed and listed in the "plugins" section of your serverless
config file
But I did install the plugin serverless-offline correctly, please can someone help me fix it.
Here is my serverless.yml file:
service: email-sender
provider:
name: aws
runtime: nodejs4.3
functions:
send:
handler: handler.send
events:
- http:
path: submissions
method: post
response:
headers:
Content-Type: "text/json"
cors:
origins:
- '*'
package:
exclude:
- node_modules/**
include:
- node_modules/serverless-offline/**
plugins:
- serverless-offline
Serverless offline is a plugin to run only on your development machine, not in production.
To enable it add the following to serverless.yml:
plugins:
- serverless-offline
and remove the following lines
include:
- node_modules/serverless-offline/**
also check your package.json and make sure it is a devDependencies.
Please ensure that serverless-offline package is included in dev dependencies, if not then add it
"serverless-offline": "3.20.2"
and run,
npm install --save-dev
This solved my issue.
To resolve this error while running an automated CI pipeline or locally, try the following:
- npm config set prefix /usr/local
- npm install -g serverless
- npm install serverless-offline -g
- npm install --save-dev
- serverless deploy --stage production --verbose
Also, check your package.json and ensure the serverless-offline package is included in devDependencies.
This fixed the issue for me.
Happy Serverless!
The error is resolved by installing the package
npm install serverless-offline -g
If the serverless package is not added, do add that:
npm i -g serverless
The terminal commands and the console logs shown below:
keerthipriyagkurtakoti#Keerthipriyas-MacBook-Pro aws-node-express-api % npm start
> aws-node-express-api#1.0.0 start /Users/keerthipriyagkurtakoti/Desktop/krishnaWorkspace/Educative/educative/aws-node-express-api
> nodemon --exec serverless offline
[nodemon] 2.0.19
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `serverless offline`
Environment: darwin, node 14.16.1, framework 3.21.0, plugin 6.2.2, SDK 4.3.2
Docs: docs.serverless.com
Support: forum.serverless.com
Bugs: github.com/serverless/serverless/issues
Error:
Serverless plugin "serverless-offline" not found. Make sure it's installed and listed in the "plugins" section of your serverless config file. Run "serverless plugin install -n serverless-offline" to install it.
[nodemon] app crashed - waiting for file changes before starting...
^C% keerthipriyagkurtakoti#Keerthipriyas-MacBook-Pro aws-node-express-api % npm install serverless-offline -g
npm WARN deprecated querystring#0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN serverless-offline#8.8.1 requires a peer of serverless#^1.60.0 || 2 || 3 but none is installed. You must install peer dependencies yourself.
+ serverless-offline#8.8.1
added 192 packages from 267 contributors in 34.928s
keerthipriyagkurtakoti#Keerthipriyas-MacBook-Pro aws-node-express-api % npm start
> aws-node-express-api#1.0.0 start /Users/keerthipriyagkurtakoti/Desktop/krishnaWorkspace/Educative/educative/aws-node-express-api
> nodemon --exec serverless offline
[nodemon] 2.0.19
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `serverless offline`
Starting Offline at stage dev (us-east-1)
Offline [http for lambda] listening on http://localhost:3002
Function names exposed for local invocation by aws-sdk:
* user: aws-node-express-api-dev-user
* test: aws-node-express-api-dev-test
* authentication: aws-node-express-api-dev-authentication
* postFeed: aws-node-express-api-dev-postFeed
┌──────────────────────────────────────────────────────────────────────────────────┐
│ │
│ ANY | http://localhost:4000/dev/user/{any*} │
│ POST | http://localhost:4000/2015-03-31/functions/user/invocations │
│ ANY | http://localhost:4000/dev/test/{any*} │
│ POST | http://localhost:4000/2015-03-31/functions/test/invocations │
│ ANY | http://localhost:4000/dev/auth/{any*} │
│ POST | http://localhost:4000/2015-03-31/functions/authentication/invocations │
│ ANY | http://localhost:4000/dev/social/{any*} │
│ POST | http://localhost:4000/2015-03-31/functions/postFeed/invocations │
│ │
└──────────────────────────────────────────────────────────────────────────────────┘
Server ready: http://localhost:4000 🚀
Enter "rp" to replay the last request
Error is shown in the picture below
The error being addressed
in the picture below:
I encountered a similar issue on bitbucket pipelines. I fixed the issue (after many trials and errors) by updating "script" section of your bitbucket-pipelines.yml file with the following:
script:
- npm install -g npm
- npm install --save-dev
- pipe: atlassian/serverless-deploy:1.1.1
variables:
AWS_ACCESS_KEY_ID: $KEY_DEFINED_ON_BITBUCKET
AWS_SECRET_ACCESS_KEY: $KEY_DEFINED_ON_BITBUCKET
Also, check your package.json and ensure the serverless-offline package and any other plugins in the serverless.yml file are included in devDependencies.
Big thanks to K Manoj Kumar's answer for giving me a clue.
If you are not using bitbucket pipeline, I feel replacing the "pipe" section on the bitbucket-pipelines.yml file with something like npm run deploy and adding "deploy": "serverless deploy" to the "scripts" section on your package.json will work.
I kept getting this error as I had the NODE_ENV set to "production" in my local dev environment.
serverless-offline does not work with this I believe. So set NODE_ENV to "development" or something that's not "production"