I'm initiating an aws-cdk project with the following structure
src
└── cdk
├── config
├── index.ts
├── pipeline.ts
└── stacks
node_modules
cdk.json
package.json
My package.json is as under
"name": "my-project",
"version": "1.0.0",
"scripts": {
"build:artifacts": "cdk synth -o tmp/artifacts",
"watch": "tsc -w",
"cdk": "./node_modules/.bin/cdk",
"cdk-check": "yarn cdk doctor./node_modules/.bin/cdk",
"typecheck": "tsc --noEmit",
"lint": "eslint --cache --cache-location ./node-modules/.eslintcache --ext=.ts,.js ./src",
"test": "yarn typecheck && yarn lint && yarn jest",
"jest": "jest"
},
"devDependencies": {
"@types/jest": "^27.5.2",
"@types/node": "10.17.27",
"@types/prettier": "2.6.0",
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"aws-cdk": "2.37.1",
"eslint": "^8.21.0",
"jest": "^27.5.1",
"ts-jest": "^27.1.4",
"ts-node": "^10.9.1",
"typescript": "~3.9.7"
},
"dependencies": {
"aws-cdk-lib": "2.37.1",
"constructs": "^10.0.0",
"source-map-support": "^0.5.21"
}
}
yarn lint and yarn typecheck runs ok
However, yarn build:artifacts returns following error
➜ src git:(feature/create-vpc) ✗ yarn build:artifacts
yarn run v1.22.18
warning package.json: No license field
$ cdk synth -o /tmp/artifacts
ENOENT: no such file or directory, open '/tmp/artifacts/manifest.json'
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
A delete node_module and yarn install everything again to no avail
Could someone please let me know why yarn build:artifacts is generating this error ??
BR
A couple of errors existed:
Firstable cdk.json app entry needed to point to index.ts "app": "npx ts-node --prefer-ts-exts src/cdk/index.ts"
index.ts needs to have app.synth() at the end as under
import 'source-map-support/register';
import * as cdk from 'aws-cdk-lib';
import { TestStack } from './pipeline';
const app = new cdk.App();
new TestStack(app, ‘TestStack', {
env: { account: ‘123456789012, region: 'us-east-1' },
});
app.synth();
hope this helps