Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

TypeError: Cannot read properties of undefined (reading 'startsWith')

default discord avatar
supakulast year
6
Generating import map
/Volumes/payload/node_modules/.pnpm/payload@3.0.0-beta.91_graphql@16.9.0_typescript@5.5.4/node_modules/payload/src/bin/generateImportMap/index.ts:69
      componentPath.startsWith('.') || componentPath.startsWith('/')
                    ^


TypeError: Cannot read properties of undefined (reading 'startsWith')
    at addPayloadComponentToImportMap (/Volumes/payload/node_modules/.pnpm/payload@3.0.0-beta.91_graphql@16.9.0_typescript@5.5.4/node_modules/payload/src/bin/generateImportMap/index.ts:69:21)
    at addToImportMap (/Volumes/payload/node_modules/.pnpm/payload@3.0.0-beta.91_graphql@16.9.0_typescript@5.5.4/node_modules/payload/src/bin/generateImportMap/index.ts:126:9)
    at iterateConfig (/Volumes/payload/node_modules/.pnpm/payload@3.0.0-beta.91_graphql@16.9.0_typescript@5.5.4/node_modules/payload/src/bin/generateImportMap/iterateConfig.ts:49:3)
    at generateImportMap (/Volumes/payload/node_modules/.pnpm/payload@3.0.0-beta.91_graphql@16.9.0_typescript@5.5.4/node_modules/payload/src/bin/generateImportMap/index.ts:143:3)
    at bin (/Volumes/payload/node_modules/.pnpm/payload@3.0.0-beta.91_graphql@16.9.0_typescript@5.5.4/node_modules/payload/dist/bin/index.js:64:16)
    at async start (file:///Volumes/payload/node_modules/.pnpm/payload@3.0.0-beta.91_graphql@16.9.0_typescript@5.5.4/node_modules/payload/bin.js:30:7)

Node.js v22.6.0
 ELIFECYCLE  Command failed with exit code 1.


related payload.config.ts:


export default buildConfig({
  admin: {
    importMap: {
      baseDir: path.resolve(dirname),
    },
    components: {
      OAuthLoginButton: {
        path: '/app/components/OAuthLoginButton/OAuthLoginButton#OAuthLoginButton',
      },
      graphics: {
        Icon: {
          path: '/app/components/Icon/Icon#Icon',
        },
        Logo: {
          path: '/app/components/Logo/Logo#Logo',
        },
      },
    },
  • default discord avatar
    paulpopuslast year

    Interesting, I just tested this and it worked for me



    graphics: {
      Icon: {
        path: '/components/Icon/index.js#Icon',
      },
      Logo: '/components/Logo/index.js#Logo',
    },


    file extension shouldnt matter here, this is in our monorepo ^

  • default discord avatar
    supakulast year

    yeah, I just pulled out all the components from the config and still get the error when generated an importmap

  • default discord avatar
    paulpopuslast year

    anything weird in the importMap.js file?

  • default discord avatar
    supakulast year

    no, I copy/pasta'd it from the template/website commit



    had to pull out the empty module as it was creating an error



    but from what I grok, I could also just blank that file out, and it should generate a new one, right?/

  • default discord avatar
    paulpopuslast year

    pretty sure yeah



    the minimum it might need is


    export const importMap = {}
  • default discord avatar
    supakulast year

    yeah, same error. pulled out all the custom components from the config, and set the importmap.js as above.



    I'll go back through what I changed to catch up



    this is beta 91, so I can also revert back to the last supported website/template beta and see if it resolves



    :facepalm:

    it was caused by something in a plugin config



    ok, appears to be related to passing my google login button into the plugin config ( OAuthLoginButton ).

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.