aws-pdk icon indicating copy to clipboard operation
aws-pdk copied to clipboard

[DOCS] Your First AWS PDK project fails with error

Open nagmesh opened this issue 4 months ago • 1 comments

Describe the issue

In the docs, when new app is setup. I failed on the typesafe api step with error

myapi-typescript-runtime: 👾 build » pre-compile » generate | npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api generate --specPath ../../../model/.api.json --outputPath . --templateDirs "typescript" --metadata '{"srcDir":"src"}'
myapi-typescript-react-query-hooks: 👾 build » pre-compile » generate | npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api generate --specPath ../../../model/.api.json --outputPath . --templateDirs "typescript/templates/client" "typescript-react-query-hooks" --metadata '{"srcDir":"src"}'
myapi-typescript-runtime: node:internal/errors:497
myapi-typescript-runtime:     ErrorCaptureStackTrace(err);
myapi-typescript-runtime:     ^
myapi-typescript-runtime: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
myapi-typescript-runtime:     at new NodeError (node:internal/errors:406:5)
myapi-typescript-runtime:     at validateString (node:internal/validators:162:11)
myapi-typescript-runtime:     at Object.join (node:path:1175:7)
myapi-typescript-runtime:     at ...redacted/test-pdk/node_modules/@aws/pdk/scripts/type-safe-api/run.js:45565:84
myapi-typescript-runtime:     at Array.map (<anonymous>)
myapi-typescript-runtime:     at ...redacted/test-pdk/node_modules/@aws/pdk/scripts/type-safe-api/run.js:45565:65
myapi-typescript-runtime:     at Array.flatMap (<anonymous>)
myapi-typescript-runtime:     at generate_next_default (...redacted/test-pdk/node_modules/@aws/pdk/scripts/type-safe-api/run.js:45562:39)
myapi-typescript-runtime:     at async ...redacted/test-pdk/node_modules/@aws/pdk/scripts/type-safe-api/run.js:45587:14 {
myapi-typescript-runtime:   code: 'ERR_INVALID_ARG_TYPE'
myapi-typescript-runtime: }
myapi-typescript-runtime: Node.js v20.8.0
myapi-typescript-react-query-hooks: node:internal/errors:497
myapi-typescript-react-query-hooks:     ErrorCaptureStackTrace(err);
myapi-typescript-react-query-hooks:     ^
myapi-typescript-react-query-hooks: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
myapi-typescript-react-query-hooks:     at new NodeError (node:internal/errors:406:5)
myapi-typescript-react-query-hooks:     at validateString (node:internal/validators:162:11)
myapi-typescript-react-query-hooks:     at Object.join (node:path:1175:7)
myapi-typescript-react-query-hooks:     at ...redacted/test-pdk/node_modules/@aws/pdk/scripts/type-safe-api/run.js:45565:84
myapi-typescript-react-query-hooks:     at Array.map (<anonymous>)
myapi-typescript-react-query-hooks:     at ...redacted/test-pdk/node_modules/@aws/pdk/scripts/type-safe-api/run.js:45565:65
myapi-typescript-react-query-hooks:     at Array.flatMap (<anonymous>)
myapi-typescript-react-query-hooks:     at generate_next_default (...redacted/test-pdk/node_modules/@aws/pdk/scripts/type-safe-api/run.js:45562:39)
myapi-typescript-react-query-hooks:     at async ...redacted/test-pdk/node_modules/@aws/pdk/scripts/type-safe-api/run.js:45587:14 {
myapi-typescript-react-query-hooks:   code: 'ERR_INVALID_ARG_TYPE'
myapi-typescript-react-query-hooks: }
myapi-typescript-react-query-hooks: Node.js v20.8.0
myapi-typescript-runtime: 👾 Task "build » pre-compile » generate" failed when executing "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api generate --specPath ../../../model/.api.json --outputPath . --templateDirs "typescript" --metadata '{"srcDir":"src"}'" (cwd: ...redacted/test-pdk/packages/api/generated/runtime/typescript)
myapi-typescript-react-query-hooks: 👾 Task "build » pre-compile » generate" failed when executing "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api generate --specPath ../../../model/.api.json --outputPath . --templateDirs "typescript/templates/client" "typescript-react-query-hooks" --metadata '{"srcDir":"src"}'" (cwd: ...redacted/test-pdk/packages/api/generated/libraries/typescript-react-query-hooks)

The only major difference is that I used yarn. Here is my projenrc file

import { MonorepoTsProject } from "@aws/pdk/monorepo";
import {
  DocumentationFormat,
  Language,
  Library,
  ModelLanguage,
  TypeSafeApiProject,
} from "@aws/pdk/type-safe-api";
import { javascript } from "projen";

// rename variable to monorepo for better readability
const monorepo = new MonorepoTsProject({
  name: "my-project",
  packageManager: javascript.NodePackageManager.YARN_CLASSIC,
  projenrcTs: true,
});

new TypeSafeApiProject({
  parent: monorepo,
  outdir: "packages/api",
  name: "myapi",
  infrastructure: {
    language: Language.TYPESCRIPT,
  },
  model: {
    language: ModelLanguage.SMITHY,
    options: {
      smithy: {
        serviceName: {
          namespace: "com.aws",
          serviceName: "MyApi",
        },
      },
    },
  },
  runtime: {
    languages: [Language.TYPESCRIPT],
  },
  documentation: {
    formats: [DocumentationFormat.HTML_REDOC],
  },
  library: {
    libraries: [Library.TYPESCRIPT_REACT_QUERY_HOOKS],
  },
  handlers: {
    languages: [Language.TYPESCRIPT],
  },
});

monorepo.synth();

Links

https://aws.github.io/aws-pdk/getting_started/your_first_aws_pdk_project.html#add-a-type-safe-api-to-your-monorepo

nagmesh avatar Oct 04 '24 20:10 nagmesh