Skip to content

Multiple ERR_MODULE_NOT_FOUND when following Flutter + Amplify + AWS Blocks quickstart step by step #241

Description

@AndroidLoop

Before opening, please confirm

Which package(s) are affected?

@aws-blocks/core

Describe the bug

Where detected two bugs:

  1. When trying to execute the command npm run blocks:dev, it prompts that a file (server.ts) does no exist.
  2. When trying to execute the command npm run blocks:generate-client, it prompts that aws core does no exist.

The first one was detected following the steps from the quickstart of AWS blocks, Flutter section, adding it to an existing Amplify Gen 2 project.

The second one was found trying to find a workaround the first bug, supposing that running the only available script would generate the others (due to these Amplify tutorials not being so explicit about running the right commands).

Expected behavior

The AWS blocks server to be up and running after following step by step the quickstart.

Reproduction steps

  1. Create a new flutter project (flutter create my_app)
  2. Add amplify to the project (npm create amplify@latest -y)
  3. Add blocks to the project (npx @aws-blocks/create-blocks-app)
  4. To be sure, run npm install within the project's root and and aws-blocks directory.
  5. In the project's root, execute npm run blocks:dev. (First bug)
  6. In the project's root, execute npm run blocks:generate-client. (Second bug)

Code snippet

PS Z:> flutter create my_app
PS Z:> cd .\my_app\
PS Z:\my_app> npm create amplify@latest -y
PS Z:\my_app> npx @aws-blocks/create-blocks-app
PS Z:\my_app> npm install
PS Z:\my_app> cd .\aws-blocks\
PS Z:\my_app\aws-blocks> npm install
PS Z:\my_app> npm run blocks:dev
PS Z:\my_app> npm run blocks:generate-client

Log output

> my_app@1.0.0 blocks:dev
> tsx watch aws-blocks/scripts/server.ts

node:internal/modules/esm/resolve:275
    throw new ERR_MODULE_NOT_FOUND(
          ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'Z:\my_app\aws-blocks\scripts\server.ts' imported from Z:\my_app\
    at finalizeResolution (node:internal/modules/esm/resolve:275:11)
    at moduleResolve (node:internal/modules/esm/resolve:865:10)
    at defaultResolve (node:internal/modules/esm/resolve:991:11)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:719:20)
    at #resolveAndMaybeBlockOnLoaderThread (node:internal/modules/esm/loader:736:38)
    at nextStep (node:internal/modules/customization_hooks:189:26)
    at resolveBaseSync (file:///Z:/my_app/node_modules/tsx/dist/register-zZ7SWseA.mjs:2:9102)
    at resolveDirectorySync (file:///Z:/my_app/node_modules/tsx/dist/register-zZ7SWseA.mjs:2:10315)
    at resolveTsPathsSync (file:///Z:/my_app/node_modules/tsx/dist/register-zZ7SWseA.mjs:2:11547)
    at resolve (file:///Z:/my_app/node_modules/tsx/dist/register-zZ7SWseA.mjs:2:13365) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///Z:/my_app/aws-blocks/scripts/server.ts'
}

Node.js v24.14.1


> my_app@1.0.0 blocks:generate-client
> cross-env NODE_OPTIONS="--conditions=aws-runtime" tsx aws-blocks/scripts/generate-client.ts

node:internal/modules/package_json_reader:301
  throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
        ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@aws-blocks/core' imported from Z:\my_app\aws-blocks\scripts\generate-client.ts
    at Object.getPackageJSONURL (node:internal/modules/package_json_reader:301:9)
    at packageResolve (node:internal/modules/esm/resolve:768:81)
    at moduleResolve (node:internal/modules/esm/resolve:859:18)
    at defaultResolve (node:internal/modules/esm/resolve:991:11)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:719:20)
    at #resolveAndMaybeBlockOnLoaderThread (node:internal/modules/esm/loader:736:38)
    at nextStep (node:internal/modules/customization_hooks:189:26)
    at resolveBaseSync (file:///Z:/my_app/node_modules/tsx/dist/register-zZ7SWseA.mjs:2:9102)
    at resolveDirectorySync (file:///Z:/my_app/node_modules/tsx/dist/register-zZ7SWseA.mjs:2:10315)
    at resolveTsPathsSync (file:///Z:/my_app/node_modules/tsx/dist/register-zZ7SWseA.mjs:2:11547) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v24.14.1

Environment

  • AWS Blocks version: 0.2.0
  • Node.js version: 24.14.1
  • Package manager (npm/yarn/pnpm): 11.11.0
  • OS: Windows 10
  • CDK version (if applicable): -

Additional context

I found a workaround by installing AWS blocks outside my project following the developer guide and copy/pasting the content of scripts directory within my project and the @aws-core directory found in node_modules within my project's node_modules. Due to this behavior I think it has to do with versioning or pulling the wrong dist version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions