Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

How to install node_modues in build stage and reuse them in deploy stage #73

Open
s1mrankaur opened this issue Oct 8, 2021 · 0 comments

Comments

@s1mrankaur
Copy link

s1mrankaur commented Oct 8, 2021

I tried using buildOutput as input for deploy stage .

In the Build details, I can see:
COMMAND_EXECUTION_ERROR: Error while executing command: bash ${CODEBUILD_SRC_DIR}/scripts/deploy.sh. Reason: exit status 57

In the code pipeline logs, it said

> frontend@0.3.1 test-ci
--
99 | > CI=true react-scripts test --env=jsdom --no-cache
100 |  
101 | internal/modules/cjs/loader.js:818
102 | throw err;
103 | ^
104 |  
105 | Error: Cannot find module '../scripts/test'
106 | Require stack:
107 | - /codebuild/output/src887073721/src/node_modules/.bin/react-scripts
108 | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
109 | at Function.resolve (internal/modules/cjs/helpers.js:80:19)
110 | at Object.<anonymous> (/codebuild/output/src887073721/src/node_modules/.bin/react-scripts:31:23)
111 | at Module._compile (internal/modules/cjs/loader.js:999:30)
112 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
113 | at Module.load (internal/modules/cjs/loader.js:863:32)
114 | at Function.Module._load (internal/modules/cjs/loader.js:708:14)
115 | at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
116 | at internal/main/run_main_module.js:17:47 {
117 | code: 'MODULE_NOT_FOUND',
118 | requireStack: [
119 | '/codebuild/output/src887073721/src/node_modules/.bin/react-scripts'
120 | ]
121 | }

I have checked that the input folder to this stage has

folderpathins3/node_modules/.bin/react-scripts
CODEBUILD_SRC_DIR=/codebuild/output/src177948730/src

If the input is source artifact and I run npm install, it works okay.

it seems to be looking into

'/codebuild/output/src177948730/src/node_modules/.bin/react-scripts'
if the input is built artifact.

My deploy project in CDK has

'bash ${CODEBUILD_SRC_DIR}/scripts/deploy.sh'

and deploy.sh has commands like:

npm run test-ci
which looks like

"test-ci": "CI=true react-scripts test --env=jsdom --no-cache", What needs to be changed to fix this issue?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant