I have a private npm package that I have published to AWS CodeArtifact so I can use it across a ReactJS App and NodeJS/Express API app.
Version 1.0.0 of this package is published to CodeArtifact.
In my ReactJS App, I have a dependency in package.json as "@name-space/name-of-package": "^1.0.0"
I’ve changed the registry for @name-space to point to the CodeArtifact URL. For all other packages I’m still using the default NPM registry (https://registry.npmjs.com). I have this configured via an .npmrc file in my ReactJs project.
When I try to deploy my ReactJS app via AWS Amplify I get an error in the build: ERR! Invalid Version: ^1.0.0
I’m new to virtually everything I’m working with here - creating private packages, CodeArtifact, and Amplify, so I’m not sure if I’m missing any steps.
I've tried removing the "^" from the version in the ReactJS package.json, but then I get ERR! Invalid Version: 1.0.0 when trying to build.
Any idea how I can get rid of this error and get a successful build of my ReactJS app deployed via Amplify?
You will also need to update your amplify.yml
to login to CodeArtifact. Here is an example...
frontend:
phases:
preBuild:
commands:
- pip3 install awscli --upgrade --user
- aws codeartifact login --tool npm --repository repository_name --domain domain_name --domain-owner domain_owner_id
- npm ci