How to define entry point of a function that's under a /dist directory?

I’m developing functions using the NodeJS runtime using TypeScript, and my compiled JavaScript code goes to a /dist directory, with the main function residing in index.js. I tried the following configuration in project.yml:

environment: {}
parameters: {}
  - name: sample
    environment: { }
    parameters: { }
    annotations: { }
      - name: hello
        binary: false
        main: 'dist/index.js'
        runtime: 'nodejs:default'
        web: true
        parameters: { }
        environment: { }
        annotations: { }
        limits: { }

It deploys without any apparent issue, but when I try to run the function, it cannot start, and I get the following error in the logs:

"2022-07-24T17:15:51.915241077Z stdout: Action entrypoint 'dist/index.js' is not a function."

If I change the main property to /dist I get something like this:

"2022-07-24T17:21:27.668525053Z stdout: Error: Cannot find module '/tmp/fP5MxYsZ'"

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I managed to solve this myself. It turns out that I had not set the main property in the package.json file to dist/index.js. The main in the project.yml is for setting the name of the entrypoint function in case its name is different than main.