aws-samples / amplify-angular-template

This is a Angular starter for building a fullstack app with AWS Amplify.
https://docs.amplify.aws/gen2
MIT No Attribution
8 stars 21 forks source link

Deployment of the template fails: node version < 18.19 #6

Open joerg-pfruender opened 2 months ago

joerg-pfruender commented 2 months ago

I deployed a forked version of this template. The deployment fails with an error:

## Completed Backend Build

244

2024-08-17T16:41:54.531Z [INFO]: ## Starting Frontend Build

245

# Starting phase: build

246

2024-08-17T16:41:54.531Z [INFO]: # Executing command: npm install -g @angular/cli

247

2024-08-17T16:42:03.970Z [WARNING]: npm

248

2024-08-17T16:42:03.976Z [WARNING]: WARN EBADENGINE Unsupported engine {

249

npm WARN EBADENGINE package: '@angular/cli@18.2.0',

250

npm WARN EBADENGINE required: {

251

npm WARN EBADENGINE npm: '^6.11.0 || ^7.5.6 || >=8.0.0',

252

npm WARN EBADENGINE node: '^18.19.1 || ^20.11.1 || >=22.0.0',

253

npm WARN EBADENGINE yarn: '>= 1.13.0'

254

npm WARN EBADENGINE },

255

npm WARN EBADENGINE current: { node: 'v18.18.2', npm: '9.8.1' }

256

npm WARN EBADENGINE }

257

npm WARN EBADENGINE Unsupported engine {

258

npm WARN EBADENGINE package: '@angular-devkit/architect@0.1802.0',

259

npm WARN EBADENGINE required: {

260

npm WARN EBADENGINE npm: '^6.11.0 || ^7.5.6 || >=8.0.0',

261

npm WARN EBADENGINE node: '^18.19.1 || ^20.11.1 || >=22.0.0',

262

npm WARN EBADENGINE yarn: '>= 1.13.0'

263

npm WARN EBADENGINE },

264

npm WARN EBADENGINE current: { node: 'v18.18.2', npm: '9.8.1' }

265

npm WARN EBADENGINE }

266

npm WARN EBADENGINE Unsupported engine {

267

npm WARN EBADENGINE package: '@angular-devkit/core@18.2.0',

268

npm WARN EBADENGINE required: {

269

npm WARN EBADENGINE npm: '^6.11.0 || ^7.5.6 || >=8.0.0',

270

npm WARN EBADENGINE node: '^18.19.1 || ^20.11.1 || >=22.0.0',

271

npm WARN EBADENGINE yarn: '>= 1.13.0'

272

npm WARN EBADENGINE },

273

npm WARN EBADENGINE current: { node: 'v18.18.2', npm: '9.8.1' }

274

npm WARN EBADENGINE }

275

npm WARN EBADENGINE Unsupported engine {

276

npm WARN EBADENGINE package: '@angular-devkit/schematics@18.2.0',

277

npm WARN EBADENGINE required: {

278

npm WARN EBADENGINE npm: '^6.11.0 || ^7.5.6 || >=8.0.0',

279

npm WARN EBADENGINE node: '^18.19.1 || ^20.11.1 || >=22.0.0',

280

npm WARN EBADENGINE yarn: '>= 1.13.0'

281

npm WARN EBADENGINE },

282

npm WARN EBADENGINE current: { node: 'v18.18.2', npm: '9.8.1' }

283

npm WARN EBADENGINE }

284

npm WARN EBADENGINE Unsupported engine {

285

npm WARN EBADENGINE package: '@schematics/angular@18.2.0',

286

npm WARN EBADENGINE required: {

287

npm WARN EBADENGINE npm: '^6.11.0 || ^7.5.6 || >=8.0.0',

288

npm WARN EBADENGINE node: '^18.19.1 || ^20.11.1 || >=22.0.0',

289

npm WARN EBADENGINE yarn: '>= 1.13.0'

290

npm WARN EBADENGINE },

291

npm WARN EBADENGINE current: { node: 'v18.18.2', npm: '9.8.1' }

292

npm WARN EBADENGINE }

293

2024-08-17T16:42:06.210Z [INFO]: added 265 packages in 11s

294

2024-08-17T16:42:06.210Z [INFO]: 49 packages are looking for funding

295

run `npm fund` for details

296

2024-08-17T16:42:06.224Z [INFO]: # Executing command: ng version

297

2024-08-17T16:42:06.258Z [WARNING]: Node.js version v18.18.2 detected.

298

The Angular CLI requires a minimum Node.js version of v18.19.

299

Please update your Node.js version or visit https://nodejs.org/ for additional instructions.

300

2024-08-17T16:42:06.262Z [ERROR]: !!! Build failed

301

2024-08-17T16:42:06.262Z [ERROR]: !!! Error: Command failed with exit code 3

302

2024-08-17T16:42:06.263Z [INFO]: # Starting environment caching...

303

2024-08-17T16:42:06.263Z [INFO]: # Environment caching completed
dataminion commented 2 months ago

This error occurs because the fork you are using isn't targeting angular 17 as a result the npm install -g @angular/cli is trying to install angular 18 which requires a newer version of node you can fix the issue by using this amplify.yml

version: 1
backend:
  phases:
    build:
      commands:
        - npm ci --cache .npm --prefer-offline
        - npx ampx pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID
frontend:
  phases:
    preBuild:
      commands:
        - nvm install 18.19.1
        - nvm use 18.19.1
        - node -v
        - npm install -g @angular/cli@18.2.1
    build:
      commands:
        - ng version
        - ng build --configuration=production
  artifacts:
    baseDirectory: dist/<!YOUR ANGULAR PROECT NAME!>/browser
    files:
      - '**/*'
  cache:
    paths:
      - .npm/**/*
      - node_modules/**/*
eunomian commented 2 months ago

Thank you. I can confirm that the solution from @dataminion worked for me.

joerg-pfruender commented 2 months ago

@dataminion Thank you so much for your help! It works fine now.

Just one comment:

For the key baseDirectory I have kept the value dist/amplify-angular-template/browser because my repository has the name "amplify-angular-template" because I've simply forked the template repo without renaming.

So the general value is "dist/{here comes the name of your repo}/browser"

dataminion commented 2 months ago

oh noes in my haste to answer a question I knew the answer to I leaked a private project codename to a public space.... ;-P thanks @joerg-pfruender I fixed it to make it a little more obvious to others.

jdegand commented 2 months ago

@dataminion You have to delete your previous comment. Right click on the previous comment and there should be an option to delete it. Editing your comment is not enough.

dataminion commented 2 months ago

yeah I only edited it for clarity I am not actually concerned about leaking the filepath from my project