Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of undefined (reading 'mainFile') #6785

Open
forgetso opened this issue Aug 8, 2024 · 0 comments
Open

Cannot read properties of undefined (reading 'mainFile') #6785

forgetso opened this issue Aug 8, 2024 · 0 comments
Labels
type: bug code to address defects in shipped code

Comments

@forgetso
Copy link

forgetso commented Aug 8, 2024

Describe the bug

When running netlify dev it crashes with node 20 and gives the error Warning: TypeError: Cannot read properties of undefined (reading 'mainFile')

netlify --version  
netlify-cli/17.26.0 linux-x64 node-v20.12.2
◈ Extracted function errorHandler from /home/chris/dev/prosopo/captcha-private/netlify/functions/errorHandler.zip.
undefined
 ›   Warning: TypeError: Cannot read properties of undefined (reading 'mainFile')
 ›       at FunctionsRegistry.registerFunction (file:///home/user/.nvm/versions/node/v20.12.2/lib/node_modules/netlify-cli/dist/lib/functions/registry.js:320:80)
 ›       at async file:///home/user/.nvm/versions/node/v20.12.2/lib/node_modules/netlify-cli/dist/lib/functions/registry.js:413:13
 ›       at async Promise.all (index 1)
 ›       at async FunctionsRegistry.scan (file:///home/user/.nvm/versions/node/v20.12.2/lib/node_modules/netlify-cli/dist/lib/functions/registry.js:374:32)
 ›       at async startFunctionsServer (file:///home/user/.nvm/versions/node/v20.12.2/lib/node_modules/netlify-cli/dist/lib/functions/server.js:279:5)
 ›       at async BaseCommand.dev (file:///home/user/.nvm/versions/node/v20.12.2/lib/node_modules/netlify-cli/dist/commands/dev/dev.js:138:31)
 ›       at async BaseCommand.parseAsync (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/netlify-cli/node_modules/commander/lib/command.js:935:5)
 ›       at async file:///home/user/.nvm/versions/node/v20.12.2/lib/node_modules/netlify-cli/bin/run.js:27:3

Main file is actually present on the function definition:

errorHandler NetlifyFunction {
  buildError: null,
  srcFiles: Set(0) {},
  blobsContext: {
    deployID: '0',
    edgeURL: 'http://localhost:33031',
    siteID: 'unlinked',
    token: '*****',
    uncachedEdgeURL: 'http://localhost:33031',
    primaryRegion: 'dev'
  },
  config: {
    functionsDirectory: '/home/user/dev/project/netlify/functions',
    functionsDirectoryOrigin: 'config',
    build: {
      environment: {},
      processing: [Object],
      services: {},
      base: undefined,
      functions: '/home/user/dev/project/netlify/functions'
    },
    dev: {
      targetPort: 8081,
      command: 'npm run -w @org/project start'
    },
    redirectsOrigin: 'config',
    functions: { '*': {} },
    plugins: [],
    headers: [],
    redirects: [ [Object], [Object], [Object] ]
  },
  directory: '/home/user/dev/project/netlify/functions',
  mainFile: '/home/user/dev/project/netlify/functions/errorHandler.zip',
  name: 'errorHandler',
  displayName: 'errorHandler',
  projectRoot: '/home/user/dev/project/packages/org-website',
  runtime: [Module: null prototype] {
    getBuildFunction: [AsyncFunction: getBuildFunction],
    invokeFunction: [AsyncFunction: invokeFunction],
    invokeFunctionDirectly: [AsyncFunction: invokeFunctionDirectly],
    name: 'js',
    onDirectoryScan: [AsyncFunction: onDirectoryScan]
  },
  timeoutBackground: 900,
  timeoutSynchronous: 10,
  settings: {
    baseDirectory: undefined,
    command: 'npm run -w @org/project start',
    frameworkPort: 8081,
    dist: '/home/user/dev/project/packages/org-website',
    framework: undefined,
    env: undefined,
    pollingStrategies: [],
    useStaticServer: false,
    clearPublishDirectory: undefined,
    plugins: undefined,
    port: 8888,
    jwtSecret: 'secret',
    jwtRolePath: 'app_metadata.authorization.roles',
    functions: '/home/user/dev/project/netlify/functions',
    functionsPort: 38299,
    frameworkHost: '127.0.0.1'
  },
  isBackground: false,
  schedule: undefined
}

Steps to reproduce

  1. Run a netlify dev project with the above versions of node and netlify
  2. Specify functions in netlify/functions after having built them with from TS using netlify functions:build --src ./src --functions ./functions

Configuration

[dev]
targetPort = 8081
command = "npm run start"

[functions]
directory = "netlify/functions"


Environment

npx envinfo --system --binaries --npmPackages netlify-cli --npmGlobalPackages netlify-cli

  System:
    OS: Linux 6.5 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (8) x64 AMD FX(tm)-8350 Eight-Core Processor
    Memory: 14.28 GB / 31.30 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.12.2/bin/yarn
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
  npmGlobalPackages:
    netlify-cli: 17.26.0
@forgetso forgetso added the type: bug code to address defects in shipped code label Aug 8, 2024
@forgetso forgetso changed the title Please replace with a clear and descriptive title Cannot read properties of undefined (reading 'mainFile') Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

1 participant