Open CodySwannGT opened 3 years ago
@CodySwannGT I am sorry you are having issues. Has anything changed in your build specification between the times it worked and when it didn't? Can you share that build spec?
Exact same build settings
version: 0.1
frontend:
phases:
preBuild:
commands:
- cd react-client
- npm install
build:
commands:
- npm run build
artifacts:
baseDirectory: /react-client/build
discardPaths: true
files:
- '**/*'
cache:
paths:
- node_modules/**/*
- react-client/node_modules/**/*
Any word on this?
I am also seeing this for my application. Please help address.
Any news? This seems to be a regression?
Just started happening on another application. Any help is greatly appreciated
Any word on this? Just experienced this issue.
I am going to open a support case via AWS console as there just seems to be tumbleweed here....
@CodySwannGT @r-moore @CodyMoore240 @nbyodai This looks to be related to the version of npm we're using:
https://github.com/npm/cli/issues/2731
We'll need to update the version we use in the default build container. As a workaround in the meantime, can you try updating npm as part of your build commands, for example:
version: 0.1
frontend:
phases:
preBuild:
commands:
- npm install npm@latest -g
...
Let us know if this doesn't work
I did give this a try and can see npm install npm@latest -g
running succesfully in the prebuild logs but it doesn't seem to have worked for me - app still shows $npm_package_version
I wonder if my environment variables are being resolved before the npm upgrade above has executed?:
Will try modifying my build script in package.json to something like this:
"build": "REACT_APP_VERSION=$npm_package_version yarn build"
Tried that and did not work
Same here for me, any news about this issue?
Is it not possible to access NPM package version when hosting with Amplify?
Just add this script to run with cross-env
"build": "cross-env REACT_APP_VERSION=$npm_package_version && craco build",
Adding the following line to the amplify.yml
file did the trick for me.
build:
commands:
- env | grep -e NEXT_PUBLIC_APP_VERSION >> .env # this line
- npm run build
I have also added the following env variable to aws amplify
NEXT_PUBLIC_APP_VERSION=$npm_package_version
Adding the following line to the
amplify.yml
file did the trick for me.build: commands: - env | grep -e NEXT_PUBLIC_APP_VERSION >> .env # this line - npm run build
I have also added the following env variable to aws amplify
NEXT_PUBLIC_APP_VERSION=$npm_package_version
This worked perfectly, thank you! I thought I tried this, but I think maybe I updated my yml file previously via the web console, but was still overwriting it with my amplify.yml file in my repo and didn't realize it.
- env | grep -e NEXT_PUBLIC_APP_VERSION >> .env
This approach is not working :(
NEXT_PUBLIC_APP_VERSION
contains "$npm_package_version" as string...
Hi there.
We have a number of Amplify apps and all of them set an environment variable called "REACT_APP_VERSION" to "$npm_package_version"
In all our previous apps, it works as intended in our code:
produces "Version 1.0.1" (or whatever)
However, on a newly deployed app, we're getting
"Version $npm_package_version"