Gatsby deployment failure on AWS Amplify - amazon-web-services

I have a gatsby portfolio page that's simply all in an index.js file.
I am having trouble deploying it on AWS Amplify, here are the build logs:
# Starting phase: preBuild
# Executing command: npm install
2021-11-02T07:59:54.079Z [INFO]: > msgpackr-extract#1.0.15 install /codebuild/output/src648320162/src/simonshampoo.io/node_modules/msgpackr-extract
> node-gyp-build
2021-11-02T07:59:54.283Z [INFO]: > lmdb-store#1.6.11 install /codebuild/output/src648320162/src/simonshampoo.io/node_modules/lmdb-store
> node-gyp-build
2021-11-02T07:59:54.534Z [INFO]: > core-js#3.18.3 postinstall /codebuild/output/src648320162/src/simonshampoo.io/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
2021-11-02T07:59:54.582Z [INFO]: [96mThank you for using core-js ([94m https://github.com/zloirock/core-js [96m) for polyfilling JavaScript standard library![0m
[96mThe project needs your help! Please consider supporting of core-js:[0m
[96m>[94m https://opencollective.com/core-js [0m
[96m>[94m https://patreon.com/zloirock [0m
[96m>[94m https://paypal.me/zloirock [0m
[96m>[94m bitcoin: bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz [0m
[96mAlso, the author of core-js ([94m https://github.com/zloirock [96m) is looking for a good job -)[0m
2021-11-02T07:59:54.588Z [INFO]: > core-js-pure#3.18.3 postinstall /codebuild/output/src648320162/src/simonshampoo.io/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"
2021-11-02T07:59:54.942Z [INFO]: > gatsby-telemetry#3.0.0 postinstall /codebuild/output/src648320162/src/simonshampoo.io/node_modules/gatsby-telemetry
> node src/postinstall.js || true
2021-11-02T07:59:55.003Z [INFO]: > gatsby-cli#4.0.0 postinstall /codebuild/output/src648320162/src/simonshampoo.io/node_modules/gatsby-cli
> node scripts/postinstall.js
2021-11-02T07:59:55.057Z [INFO]: > gatsby#4.0.1 postinstall /codebuild/output/src648320162/src/simonshampoo.io/node_modules/gatsby
> node scripts/postinstall.js
2021-11-02T07:59:56.402Z [WARNING]: npm
2021-11-02T07:59:56.403Z [WARNING]: WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#2.3.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2021-11-02T07:59:56.407Z [INFO]: added 1667 packages from 742 contributors and audited 1668 packages in 46.524s
2021-11-02T07:59:57.367Z [INFO]: 290 packages are looking for funding
run `npm fund` for details
2021-11-02T07:59:57.369Z [INFO]: found 17 vulnerabilities (7 moderate, 9 high, 1 critical)
run `npm audit fix` to fix them, or `npm audit` for details
2021-11-02T07:59:57.437Z [INFO]: # Completed phase: preBuild
# Starting phase: build
# Executing command: npm run build
2021-11-02T07:59:57.634Z [INFO]: > new-portfolio#1.0.0 build /codebuild/output/src648320162/src/simonshampoo.io
> gatsby build
2021-11-02T07:59:58.185Z [WARNING]: error Gatsby requires Node.js 14.15.0 or higher (you have v12.21.0).
Upgrade Node to the latest stable release: https://gatsby.dev/upgrading-node-js
2021-11-02T07:59:58.502Z [WARNING]: npm
2021-11-02T07:59:58.502Z [WARNING]: ERR! code ELIFECYCLE
npm ERR! errno 1
2021-11-02T07:59:58.504Z [WARNING]: npm
2021-11-02T07:59:58.505Z [WARNING]: ERR! new-portfolio#1.0.0 build: `gatsby build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the new-portfolio#1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-11-02T07:59:58.509Z [WARNING]:
2021-11-02T07:59:58.510Z [WARNING]: npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-11-02T07_59_58_505Z-debug.log
2021-11-02T07:59:58.510Z [HELP]: Outputting the npm debug log
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/root/.nvm/versions/node/v12.21.0/bin/node',
1 verbose cli '/root/.nvm/versions/node/v12.21.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'build'
1 verbose cli ]
2 info using npm#6.14.11
3 info using node#v12.21.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle new-portfolio#1.0.0~prebuild: new-portfolio#1.0.0
6 info lifecycle new-portfolio#1.0.0~build: new-portfolio#1.0.0
7 verbose lifecycle new-portfolio#1.0.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle new-portfolio#1.0.0~build: PATH: /root/.nvm/versions/node/v12.21.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/codebuild/output/src648320162/src/simonshampoo.io/node_modules/.bin:/usr/local/rvm/gems/ruby-2.4.6/bin:/usr/local/rvm/gems/ruby-2.4.6#global/bin:/usr/local/rvm/rubies/ruby-2.4.6/bin:/usr/local/rvm/bin:/root/.yarn/bin:/root/.config/yarn/global/node_modules/.bin:/root/.nvm/versions/node/v12.21.0/bin:/root/.local/bin:/root/.local/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.dotnet/tools
9 verbose lifecycle new-portfolio#1.0.0~build: CWD: /codebuild/output/src648320162/src/simonshampoo.io
10 silly lifecycle new-portfolio#1.0.0~build: Args: [ '-c', 'gatsby build' ]
11 silly lifecycle new-portfolio#1.0.0~build: Returned: code: 1 signal: null
12 info lifecycle new-portfolio#1.0.0~build: Failed to exec build script
13 verbose stack Error: new-portfolio#1.0.0 build: `gatsby build`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/root/.nvm/versions/node/v12.21.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:314:20)
13 verbose stack at ChildProcess.<anonymous> (/root/.nvm/versions/node/v12.21.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:314:20)
13 verbose stack at maybeClose (internal/child_process.js:1022:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid new-portfolio#1.0.0
15 verbose cwd /codebuild/output/src648320162/src/simonshampoo.io
16 verbose Linux 4.14.248-189.473.amzn2.x86_64
17 verbose argv "/root/.nvm/versions/node/v12.21.0/bin/node" "/root/.nvm/versions/node/v12.21.0/bin/npm" "run" "build"
18 verbose node v12.21.0
19 verbose npm v6.14.11
20 error code ELIFECYCLE
21 error errno 1
22 error new-portfolio#1.0.0 build: `gatsby build`
22 error Exit status 1
23 error Failed at the new-portfolio#1.0.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
2021-11-02T07:59:58.513Z [ERROR]: !!! Build failed
2021-11-02T07:59:58.513Z [ERROR]: !!! Non-Zero Exit Code detected
2021-11-02T07:59:58.513Z [INFO]: # Starting environment caching...
2021-11-02T07:59:58.513Z [INFO]: # Environment caching completed
Terminating logging...
It says that my node is outdated, but I do node -v in the project directory and it says I have v14.8.1, so I am confused. Is there another problem? public subdirectory was previously gitignored, so I removed it from there, but that doesn't seem to do anything. I can't find much information about deployment failures on Amplify since it's supposed to be straightforward. Do I have to use nvm? It also won't even deploy on Github pages-- it just shows the "Gatsby Minimal Starter" page in my repo.

I think there's a mismatching Node version between your local environment and the AWS Amplify's. If you run different versions of Node, the installed dependencies in the npm install will be different so your application will behave differently in both environments, assuming that it builds locally (if don't, there might be another underlying problem).
As you pointed, you can use nvm to set the provision version. Based on How to change Node Version in Provision Step in Amplify Console you can try:
frontend:
phases:
preBuild:
commands:
- nvm install your_local_node_version
Using a .nvmrc file in the root of the project should also work. You can set it directly by:
node -v > .nvmrc
Out of the scope of the question: /public directory should be always ignored because it's autogenerated in each build, so it will be overridden. There's no point in pushing it and it will save you MB bandwidth.

Related

AWS AppRunner Breaks When Using Custom Instance Role

When launching my container with AppRunner & the default instance role (AWS's built in role), my app immediately fails when it tries to talk to SecretsManager.
This is expected, because the default role doesn't have those permissions.
When I create a custom role with the required permissions though, I see unexpected behavior.
The app instead hangs for almost 5 minutes, before failing with these error messages:
11-01-2022 01:45:14 PM npm ERR! /root/.npm/_logs/2022-11-01T20_41_26_038Z-debug-0.log
11-01-2022 01:45:14 PM npm ERR! A complete log of this run can be found in:
11-01-2022 01:45:14 PM npm ERR! command sh -c -- npx prisma migrate deploy && node ./dist/src/main
11-01-2022 01:45:14 PM npm ERR! signal SIGTERM
11-01-2022 01:45:14 PM npm ERR! command failed
11-01-2022 01:45:14 PM npm ERR! path /
11-01-2022 01:41:32 PM No pending migrations to apply.

AWS CodePipeline execute failed in deploying Nodejs app in Elastic Beanstalk

I know its a repetitive question but I didn't see any solution out there.
I deployed Nodejs app in Elastic Beanstalk through AWS CodePipeline. It was running perfect but after AWS announces a newer version of Linux OS, it's health became degraded and the deployment after this will also fail by CodePipeline.
So I decided to upgrade the Linux version but after that, the problem is didn't resolve and it shows me this error.
I checked eb-engine.log and I came to know that one of the nodejs package is didn't install by NPM.
2022/02/06 10:24:24.575676 [ERROR] An error occurred during execution
of command [app-deploy] - [Use NPM to install dependencies]. Stop
running the command. Error: Command /bin/sh -c npm --production
install failed with error exit status 1. Stderr:sharp: Installation
error: EACCES: permission denied, mkdir '/root/.npm/_libvips' npm WARN
newbackend#1.0.0 No description npm WARN newbackend#1.0.0 No
repository field.
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! sharp#0.30.0
install: (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy) npm ERR! Exit status 1 npm ERR! npm ERR!
Failed at the sharp#0.30.0 install script. npm ERR! This is probably
not a problem with npm. There is likely additional logging output
above.
npm ERR! A complete log of this run can be found in: npm ERR!
/root/.npm/_logs/2022-02-06T10_24_24_562Z-debug.log
2022/02/06 10:24:24.575682 [INFO] Executing cleanup logic 2022/02/06
10:24:24.575792 [INFO] CommandService Response:
{"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine
execution has encountered an
error.","returncode":1,"events":[{"msg":"Instance deployment: You
didn't specify a Node.js version in the 'package.json' file in your
source bundle. The deployment didn't install a specific Node.js
version.","timestamp":1644143057,"severity":"INFO"},{"msg":"Instance
deployment: 'npm' failed to install dependencies that you defined in
'package.json'. For details, see 'eb-engine.log'. The deployment
failed.","timestamp":1644143064,"severity":"ERROR"},{"msg":"Instance
deployment failed. For details, see
'eb-engine.log'.","timestamp":1644143064,"severity":"ERROR"}]}]}
2022/02/06 10:24:24.575979 [INFO] Platform Engine finished execution
on command: app-deploy
{
"name": "newbackend",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "node server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.1069.0",
"cors": "^2.8.5",
"cryptr": "^6.0.2",
"dotenv": "^10.0.0",
"express": "^4.17.2",
"express-validator": "^6.14.0",
"influx": "^5.9.2",
"jsonwebtoken": "^8.5.1",
"moment": "^2.29.1",
"mongoose": "^6.2.0",
"morgan": "^1.10.0",
"multer": "^1.4.4",
"sharp": "^0.30.0",
"validator": "^13.7.0"
}
}
This is my package.json file. It is a simple nodejs app that serves as an API. Now the problem is with the installation of sharp package. If something is missing, please correct me.
I know there is a problem with NPM install but I don't know how to resolve this on AWS CodePipeline.
Any help will be appreciated.
Thanks

How to solve the error while building a VueJS project?

I am using VueJS for front-end and Django on back-end. For production I moved all my VueJS compiled bundel to Static/dist in django. And I blocked the content of index.html in VueJS to base.html in django. And changed the url.py such that when localhost:8000 is called it gives base.html which gives index.html of VueJS.
When I am trying to build using npm run buid it is throwing errors as shown
ERROR Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! e_cell_frontend#0.1.0 build: `vue-cli-service build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the e_cell_frontend#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2021-08-05T04_54_44_578Z-debug.log
The log file is as shown:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build' ]
2 info using npm#6.14.4
3 info using node#v10.19.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle e_cell_frontend#0.1.0~prebuild: e_cell_frontend#0.1.0
6 info lifecycle e_cell_frontend#0.1.0~build: e_cell_frontend#0.1.0
7 verbose lifecycle e_cell_frontend#0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle e_cell_frontend#0.1.0~build: PATH: /usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/vagrant/VueJS/e_cell_frontend/node_modules/.bin:/home/vagrant/.vscode-server/bin/c3f126316369cd610563c75b1b1725e0679adfb3/bin:/home/vagrant/.local/bin:/home/vagrant/.vscode-server/bin/c3f126316369cd610563c75b1b1725e0679adfb3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle e_cell_frontend#0.1.0~build: CWD: /home/vagrant/VueJS/e_cell_frontend
10 silly lifecycle e_cell_frontend#0.1.0~build: Args: [ '-c', 'vue-cli-service build' ]
11 silly lifecycle e_cell_frontend#0.1.0~build: Returned: code: 1 signal: null
12 info lifecycle e_cell_frontend#0.1.0~build: Failed to exec build script
13 verbose stack Error: e_cell_frontend#0.1.0 build: `vue-cli-service build`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:198:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:198:13)
13 verbose stack at maybeClose (internal/child_process.js:982:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid e_cell_frontend#0.1.0
15 verbose cwd /home/vagrant/VueJS/e_cell_frontend
16 verbose Linux 5.4.0-73-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "build"
18 verbose node v10.19.0
19 verbose npm v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error e_cell_frontend#0.1.0 build: `vue-cli-service build`
22 error Exit status 1
23 error Failed at the e_cell_frontend#0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
I tried to clear the cache, delete node_modules and reinstalling them but there is no use. Can any one help me solving this problem.
I solved the problem. The thing is you need to remember that you need to run npm run serve first to check is there any errors in the code and then build it. I had a typo and forgot execute npm run serve so I am unaware of original errors. So run npm run server if all is good. The build it.

AWS amplify don't deploy build infinit

I have a project to react to and I want to deploy it on AWS Amplify, locally I run the build perfectly, but when I do it on AWS it is compiling infinitely until I get a time out error. What am I doing wrong? I'm new to it and I couldn't find anything related
2020-12-30T21:20:07.282Z [WARNING]:
2020-12-30T21:20:07.288Z [INFO]: added 2085 packages from 1294 contributors and audited 2098 packages in 31.209s
2020-12-30T21:20:08.604Z [INFO]: 96 packages are looking for funding
run `npm fund` for details
2020-12-30T21:20:08.605Z [INFO]: found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
2020-12-30T21:20:08.633Z [INFO]: # Completed phase: preBuild
# Starting phase: build
# Executing command: npm run build
2020-12-30T21:20:08.801Z [INFO]: > monetiz-web#0.1.0 build /codebuild/output/src941862754/src/monetiz-app
> node scripts/build.js
2020-12-30T21:20:09.455Z [INFO]: Creating an optimized production build...
2020-12-30T21:21:08.746Z [INFO]: Compiled successfully.
```
Build Settings
```
version: 1
frontend:
phases:
preBuild:
commands:
- npm install
build:
commands:
- npm run build
- node ./node_modules/gulp/bin/gulp.js
artifacts:
# IMPORTANT - Please verify your build output directory
baseDirectory: /build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
```

I got issue with ember application after cloning disk

I began to learn ember and did working app. It was working well. Then I had to change my hard disk to ssd by cloning my old disk/ After cloning i restore my ember app from bup and tried to start it. And got error.
C:\inetpub\tracker> npm start
> tracker#0.0.0 start C:\inetpub\tracker
> ember serve
The "id" argument must be of type string. Received undefined
Stack Trace and Error Report: C:\Users\tnfoms\AppData\Local\Temp/error.dump.90e842d8b8af33fd44bc24b48197a6bd.log
An error occurred in the constructor for ember-data at C:\inetpub\tracker\node_modules\ember-data
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tracker#0.0.0 start: `ember serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tracker#0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\tnfoms\AppData\Roaming\npm-cache\_logs\2020-07-04T17_45_40_052Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start'
1 verbose cli ]
2 info using npm#6.14.4
3 info using node#v12.18.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle tracker#0.0.0~prestart: tracker#0.0.0
6 info lifecycle tracker#0.0.0~start: tracker#0.0.0
7 verbose lifecycle tracker#0.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle tracker#0.0.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\inetpub\tracker\node_modules\.bin;C:\Python38\Scripts\;C:\Python38\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Brackets\command;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files\watchman;C:\Users\tnfoms\AppData\Local\Microsoft\WindowsApps;C:\Users\tnfoms\.dotnet\tools;C:\Users\tnfoms\AppData\Local\atom\bin;C:\Users\tnfoms\AppData\Roaming\npm;C:\Users\tnfoms\AppData\Local\Programs\Git\cmd
9 verbose lifecycle tracker#0.0.0~start: CWD: C:\inetpub\tracker
10 silly lifecycle tracker#0.0.0~start: Args: [ '/d /s /c', 'ember serve' ]
11 silly lifecycle tracker#0.0.0~start: Returned: code: 1 signal: null
12 info lifecycle tracker#0.0.0~start: Failed to exec start script
13 verbose stack Error: tracker#0.0.0 start: `ember serve`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:315:20)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid tracker#0.0.0
15 verbose cwd C:\inetpub\tracker
16 verbose Windows_NT 10.0.17763
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v12.18.0
19 verbose npm v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error tracker#0.0.0 start: `ember serve`
22 error Exit status 1
23 error Failed at the tracker#0.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
I tried to reinstall node, ember but unsuccessfully
When in doubt
rm -rf node_modules && npm install
Sometimes npm just gets borked and you have to blow it away and start fresh