Amplify CLI: An error occured during the push operation: Cannot read property 'extensions' of null - aws-amplify-cli

Is there a way to resolve this issue without deleting the project's amplify directory and beginning from scratch?
Steps to reproduce:
Clone Git repository containing an Amplify CLI project
Update Node version from 8.16.1 to 10.17.0 (nvm install 10.17)
Update Amplify CLI version from 1.8.2 to 4.2.0 (npm i -g #aws-amplify/cli#4.2.0)
Initialize Amplify (amplify init and choose existing environment)
Deploy using Amplify CLI (amplify push)
Resulting error:
✖ An error occurred when pushing the resources to the cloud
Cannot read property 'extensions' of null
An error occured during the push operation: Cannot read property 'extensions' of null

A project root file named .graphqlconfig.yml was causing the error:
projects:
myappname:
schemaPath: src/graphql/schema.json
excludes:
- ./amplify/**
extensions:
amplify:
graphQLApiId: xxxxxxxxxxxxxxxxxxxxxxxxxx
endpoints:
prod: >-
https://xxxxxxxxxxxxxxxxxxxxxxxxxx.appsync-api.us-west-2.amazonaws.com/graphql
in our case, we installed Node version 12.13.1, used Amplify CLI version 4.4.0, and deleted the file. Then amplify push succeeded.

Related

Dependency error while creating a Strapi app

While creating a Strapi app using NPM or Yarn I get the following error:
PS: My node and NPM versions are 14.19.1 and 6.14.16 respectively
npx: installed 103 in 10.123s
Creating a quickstart project.
Creating a new Strapi application at /home/user/projects/backend-app.
Creating files.
Error while installing dependencies:
Keep trying!
Oh, it seems that you encountered errors while installing dependencies in your project.
Don't give up, your project was created correctly.
Fix the issues mentioned in the installation errors and try to run the following command:
cd /home/user/projects/backend-app && yarn install

Android - `main` module field for "react-native-gesture-handler" lib that could not be resolved in Azure CI & its working fine in local machine

I am working with the azure pipeline for CICD for React native app. I am using macOS Big Sur (11.4) and Android Studio 4.2.2 as a local machine to create and test the app. App working fine on the local machine without any warning or issue. However, when I am pushing the code on the Azure pipeline it is giving me errors as below,
* /Users/runner/work/1/s/node_modules/react-native-gesture-handler/src/index.ts/index(.native|.android.jsx|.native.jsx|.jsx|.android.js|.native.js|.js|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.json|.native.json|.json).
Error: While trying to resolve module `react-native-gesture-handler` from file `/Users/runner/work/1/s/index.js`, the package `/Users/runner/work/1/s/node_modules/react-native-gesture-handler/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/runner/work/1/s/node_modules/react-native-gesture-handler/src/index.ts`. Indeed, none of these files exist:
* /Users/runner/work/1/s/node_modules/react-native-gesture-handler/src/index.ts(.native|.android.jsx|.native.jsx|.jsx|.android.js|.native.js|.js|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.json|.native.json|.json)
* /Users/runner/work/1/s/node_modules/react-native-gesture-handler/src/index.ts/index(.native|.android.jsx|.native.jsx|.jsx|.android.js|.native.js|.js|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.json|.native.json|.json)
at DependencyGraph.resolveDependency (/Users/runner/work/1/s/node_modules/metro/src/node-haste/DependencyGraph.js:436:17)
at Object.resolve (/Users/runner/work/1/s/node_modules/metro/src/lib/transformHelpers.js:317:42)
at resolve (/Users/runner/work/1/s/node_modules/metro/src/DeltaBundler/traverseDependencies.js:629:33)
at /Users/runner/work/1/s/node_modules/metro/src/DeltaBundler/traverseDependencies.js:645:26
at Array.reduce (<anonymous>)
at resolveDependencies (/Users/runner/work/1/s/node_modules/metro/src/DeltaBundler/traverseDependencies.js:644:33)
at /Users/runner/work/1/s/node_modules/metro/src/DeltaBundler/traverseDependencies.js:329:33
at Generator.next (<anonymous>)
at asyncGeneratorStep (/Users/runner/work/1/s/node_modules/metro/src/DeltaBundler/traverseDependencies.js:137:24)
at _next (/Users/runner/work/1/s/node_modules/metro/src/DeltaBundler/traverseDependencies.js:159:9)
info Run CLI with --verbose flag for more details.
> Task :app:bundleMasterReleaseJsAndAssets FAILED
> Task :app:mergeUatDebugResources
FAILURE: Build failed with an exception.
My observation is that the Azure pipeline does not have macOS Big Sur as Agent. My local machine changes some configurations to support the latest Android studio and macOS and the azure pipeline agent does not support macOS Big Sur reason it is not able to find it
.
NOTE: I have tried all clean processes like yarn, pod, or delete node_module.
[azure-devops]
I have got the solution for the issue.
Actually, the latest version of macOS Big Sur (11.4) was not having a node install on VM.
I did some changes in the pipeline.
pool:
vmImage: macOS-11
steps:
- checkout: self
persistCredentials: true
clean: true
- task: NodeTool#0
displayName: 'Install Node'
inputs:
versionSpec: 'v16.6.2' # you can use your desired version here
- script: yarn install
displayName: Install Dependencies

AWS install github private package in codeBuild

Hi I have codepipeline to deploy my angular app, and in that app I am using my private github package. Everything is working locally etc. But on codeBuild I have no idea how to register into github package repository.
my buildspec looks like:
version: 0.2
env:
variables:
S3_BUCKET: "{{s3_bucket_url}}"
BUILD_ENV: "{{BUILD_ENV}}"
BUILD_FOLDER: "dist"
phases:
install:
runtime-versions:
nodejs: 14
pre_build:
commands:
- echo Installing source NPM dependencies...
- npm install
- npm install -g #angular/cli
build:
commands:
- echo Build started on `date` with $BUILD_ENV flag.
- ng build $BUILD_ENV
post_build:
commands:
- echo Build completed on `date`
artifacts:
files:
- '**/*'
base-directory: 'dist*'
if fails on npm install because 404 Not Found - GET https://registry.npmjs.org. For example in github actions I just simply define registry-url: 'https://npm.pkg.github.com' and thats correct.
Thanks for help :)
It fails because, in the execution context of the CodeBuild process, access to the repo containing the GitHub package is restricted, so it can't find the package because it doesn't have access to the repo's packages. You will need to authenticate to the GitHub Package API.
One way to authenticate is to create a Personal Access Token, include it in your CodeBuild Environment by linking a secret in the SecretsManager, then accessing that token in your buildspec script in the env section:
Create a personal access token: In GitHub, create a Personal access token with the read:packages permission. Here's a link to a tutorial on how to do that.
Register token as a secret in Secrets Manager: In SecretsManager, create a secret with one entry. Name the key of the entry GH_PERSONAL_ACCESS_TOKEN, and in the value field, provide the token that you created in step 1. Pick a descriptive name for your secret (something like codebuild/gh_token). Take note of the secret's name.
Authenticate to GitHub Packages using the Personal Access Token: In your buildspec script, you will need to retrieve the secret containing your Personal Access Token, then use that to authenticate before you run the npm install command:
env:
secrets-manager:
GH_PERSONAL_ACCESS_TOKEN: {SECRET_ARN}:PERSONAL_ACCESS_TOKEN # <- replace {SECRET_ARN} with arn of secret
phases:
#...
pre_build:
commands:
- echo Installing source NPM dependencies...
# this is needed to set the url where the package is located
- npm config set #OWNER:registry https://npm.pkg.github.com # <- replace OWNER with the organization/owner name
# this is needed to set the personal access token that we created
- npm config set //npm.pkg.github.com/:_authToken $GH_PERSONAL_ACCESS_TOKEN
- npm install
- npm install -g #angular/cli

The Amplify CLI can NOT find command: pull

I have just installed amplify cli through the command:
npm install #aws-amplify/cli
It mentions it has installed version 4.2.0.
Following the directions of the document below, I tried to run an "Amplify Pull" command to rearrange my files based on the contents on the cloud:
https://aws-amplify.github.io/docs/cli-toolchain/quickstart
However it tells me that The Amplify CLI can NOT find command: pull
Is it correct? Which command should I run instead of this one?
Can you confirm you ran npm install -g #aws-amplify/cli (note the -g flag)? Otherwise, you may have an older global amplify, while your local project has the newer amplify.
which amplify should return something like /usr/local/bin/amplify
amplify --version should return 4.2.0
It seems like changing the F (capital) to f (lowercase) solved my issue:
amplify remove Function
The Amplify CLI can NOT find command: remove Function
Scanning for plugins...
amplify remove function
No resources added for this category
p.s (Function is the name of the category)

npm run build command error

I'm trying to use install Amazon cognito Identity SDK for JavaScript by using NPM and Web-pack. Once it is done, I wanted to build the application bundle using 'npm run build'.
But it displays the following error
'Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.output.path: The provided value "dist" is not an absolute path!'
How can I correct this?