AWS CodeBuild error: Major version of alias '14.x' is not supported in runtime 'nodejs' - aws-codebuild

I have a confusing issue with AWS CodeBuild. I am getting the following error:
Major version of alias '14.x' is not supported in runtime 'nodejs'
When I update the buildspec to simply be "14" I get slightly more information on the error:
Message: Unknown runtime version named '14' of nodejs. This build image has the following versions: 10, 12
We have been using this CodeBuild project for a long time using 12.x and now require to update to 14.x. We have updated the buildspec as follows:
version: 0.2
phases:
install:
runtime-versions:
nodejs: 14.x
build:
commands:
- "npm i"
- "npm run build"
- "npm run db:migrate"
artifacts:
files:
- "all"
- "of"
- "our"
- "files"
Additionally, our CodeBuild is already on the latest version of the CodeBuild image. I have even re-built the CodeBuild project to make sure it is the latest and still the same issue:
aws/codebuild/amazonlinux2-x86_64-standard:3.0
Thank you in advance for any advice.

Thankfully we have solved this now!
The issue was with the CodeBuild image:
aws/codebuild/amazonlinux2-x86_64-standard:3.0
As per the available runtimes documentation it turns out we cannot use Amazon Linux 2 at all, we had to change to "Ubuntu Standard 5".
I hope this helps someone in the future.

If you absolutely need to use Amazon Linux 2 instead of Ubuntu, you can install Node 14 using the pre-installed n package in CodeBuild:
version: 0.2
phases:
install:
commands:
- n 14.18.3
build:
commands:
- npm i #etc
In our case we needed to build dependencies to run in Lambda. Since Lambda runs a version of Amazon Linux 2, building these dependencies in Ubuntu didn't work (for complicated sub-dependency reasons).
Tried and didn't work:
uninstall and install node in CodeBuild: when we ran node --version it still said 12
install and manage versions with nvm: ran into problems getting the nvm command to register
Then we realized that n was already pre-installed in CodeBuild and managing the node version.
In the end, no complicated commands needed.

select the build image that supports your runtime from here https://docs.aws.amazon.com/codebuild/latest/userguide/available-runtimes.html

Related

npm run dev not working with sveltekit/vite project

whenever i run this command: npm run dev, I get the following error. this is a sveltekit and vite (which i'm very new to) project.
> my-app#0.0.1 dev
> vite dev
failed to load config from /home/believe/Documents/my-app/vite.config.js
error when starting dev server:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '#sveltejs/kit' imported from /home/believe/Documents/my-app/vite.config.js.timestamp-1659118538332.mjs
at new NodeError (node:internal/errors:363:5)
at packageResolve (node:internal/modules/esm/resolve:698:9)
at moduleResolve (node:internal/modules/esm/resolve:739:18)
at Loader.defaultResolve [as _resolve] (node:internal/modules/esm/resolve:853:11)
at Loader.resolve (node:internal/modules/esm/loader:89:40)
at Loader.getModuleJob (node:internal/modules/esm/loader:242:28)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:73:40)
at link (node:internal/modules/esm/module_job:72:36)
IMHO, using / switching-to the latest version of node should ideally resolve this issue. I had faced this error, and switching to the latest version of node is what worked for me.
I have found that installing the nvm (node version manager) cli package is one of the best and handy ways to address and handle such situations. This is because, it will let you install and manage multiple versions of node, so that you can switch node versions, between projects, as needed per relevant dependencies.
For eg., in this case, I would just say nvm use latest in the project cli, and nvm will switch to the latest node version (if/where installed ==> node v18.7.0 w/ npm 8.15.00 as of now, for me, for eg. ).
At that, nvm ls lists all the installed node versions on that system/ environment, and points to the one in use at the moment. Very handy!
More info on nvm here: http://nvm.sh/
[* Since you have not mentioned the OS/ENV and Terminal etc., I can not unfortunately (at this time) share specific install instructions, and am hence pointing to the nvm git. Hope you understand. :) ]
Hope this helps; have a nice day! :)

Serverless framework running Java code hangs

I'm running Serverless 2.15.0 with Node 14.15.0. I've tried installing both with npm i -g and by using the curl script in the tutorial. I have Maven 3.6.3 installed
When I try to run a simple Java "hello world" function locally, I get this message:
Serverless: Building Java bridge, first invocation might take a bit longer.
Then Serverless just hangs. No error message, nothing. When I try to run with SLS_DEBUG=*, there are no messages after that point.
The only thing I've been able to Google is this, but there isn't any resolution to the problem. The other thing I've found is this but there seems to be no java directory where Serverless is installed, so I can't manually compile the pom file.
Anyone know how to fix this problem?
The problem is that they moved the path of the java runtime wrapper. Base paths differ regarding install location.
NVM (global installation)
cd ~/.nvm/versions/node/v16.13.1/lib/node_modules/serverless/lib/plugins/aws/invoke-local/runtime-wrappers/java
mvn package
NPM (global installation)
cd ~/.npm-global/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/runtimeWrappers/java
mvn package
Homebrew
cd /usr/local/Cellar/serverless/2.29.0/libexec/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/runtimeWrappers/java
mvn package
Replace 2.29.0 with installed serverless version.

Azure Functions func host start Error: "The gRPC binary module was not installed."

yesterday the VS Code informed me to update azure-functions-core-tools and after updating it, this error was displayed to me after I ran "func host start" :
Couldn't require bundle, falling back to Worker.js. Error: The gRPC binary module was not installed.This may be fixed by running "npm rebuild"
any idea on how to fix this?I tried npm rebuild and it does not worked.
This error often indicates that the grpc library was installed for a platform that is different from the one it is running on. The solution is to run npm install with extra arguments that describe the platform the library will run on. These options are described in the node-pre-gyp README.
For example, to install grpc for use on Node 10.0.0 on a 64-bit Linux that is not Alpine Linux, you can use the following command:
npm install --target=10.0.0 --target_arch=x64 --target_platform=linux --target_libc=glibc
Note: the target_libc option should be omitted for platforms other than Linux.
after 2 hours, installing x86 version of azure-functions-core-tools resolved the error. but this may not be the best solution.

Moonmail installation issue - Command "project" not found

I'm initializing Moonmail and following the readme, executing the following command:
sls project init -c -n your-lower-case-project-name
I'm getting the following:
Command "project" not found, Run "serverless help" for...
It seems that Serverless no longer has the "project" command (since version 0.5) and it has been replaced with "service" (which works a little differently).
What would be the way forward here?
Although they say that Moonmail supports version 0.5.2 or higher, it's not true. You need to use version 0.5x of the Serverless Framework and you can't use any version 1.x because 1.x is a complete rewrite.
Unfortunately, the solution is to uninstall the current Serverless Framework and install an old version.
npm -g uninstall serverless
npm -g install serverless#0.5.6

Travis not installing npm modules

I'm new to travis- I'm trying to get it to install my npm modules for my project and can't even get past that. "npm install" and "npm test" work fine on my computer (a mac). However, when I push my commits to travis it complains that:
Error: No compatible version found: ini#'^1.2.0'
Valid install targets:
npm ERR! ["1.0.0","1.0.1","1.0.2","1.0.3","1.0.4","1.0.5","1.1.0","1.2.0","1.2.1","1.3.0"]
Note that ini is not something I was originally including in my package.json, but it is depended on by something that I am using. I tried explicitly adding the 1.2.0 version of ini to my package.json but it still complains. I get similar complaints about other upstream dependencies.
Is there something about how travis is doing npm install that greatly differs from my local machine where it is working fine? Really stumped here.
Here's a link to my latest travis failed build: https://travis-ci.org/infomofo/chrome-angular-md-template/builds/35592993
This is due to the NPM version coming with Node.js 0.8. It doesn't support the ^ syntax for declaring dependecies.
You could either use Node.js instead:
node_js: 0.10
Or you could update npm, which would bring support for the dependency version:
before_install: npm update -q