This documentation seems to be missing a step, but I don't know what it is missing exactly. After running this:
func init MyFunctionProj --docker
(and then choose typescript)
cd MyFunctionProj/
func new --name MyHttpTrigger --template "HttpTrigger"
(and then modify the functions.json)
func host start
I can see these errors:
[6/24/19 4:51:51 PM] Job host started
[6/24/19 4:51:51 PM] The following 1 functions are in error:
[6/24/19 4:51:51 PM] MyHttpTrigger: Invalid script file name configuration. The 'scriptFile' property is set to a file that does not exist.
I am using:
Function Runtime Version: 2.0.12507.0
Thank you
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
I have realized that I don't have this issue if I initialize the project using "javascript" instead of "typescript", I think that are missing a step that builds the code and puts it inside a "/dist" directory.
I've opened this Pull Request that adds the required steps for typescript:
https://github.com/MicrosoftDocs/azure-docs/compare/master...dougmolineux:patch-1
@dougmolineux Thank you for your feedback & contribution towards MS Docs! We will review and update as appropriate.
You are very welcome @mike-urnun-msft !
Please let me know if I need to add any more details, thank you for your work on this documentation.
@dougmolineux closing the issue as per comment in the PR#33918
Thank you for taking the time to submit a fix for this issue.
In messing around with this issue, I am wondering if this is actually a template bug.
@ColbyTresness I think that there may be a bug in the HTTP template for Typescript. Are you able to get the Typescript template to run correctly?
@mhoeger the HTTPTrigger Typescript template doesn't have the scriptFile
setting. How is it getting added?
{
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
}
],
"scriptFile": "../dist/MyHttpTrigger/index.js"
}
The scriptFile setting has to be added on creation (and not the template), since the path depends on the name of the function it refers to. I tried this in both VS Code and the core tools and it's working as intended.
@ColbyTresness are you running on Windows?
Yes
Ok I can reproduce it so I’ll take it offline.
@dougmolineux we have determined that the correct commands to start a TypeScript project locally are:
npm install
npm start
We have updated the relevant articles as appropriate. Thanks for pointing this out to us and for your help fixing it!
Most helpful comment
@dougmolineux we have determined that the correct commands to start a TypeScript project locally are:
We have updated the relevant articles as appropriate. Thanks for pointing this out to us and for your help fixing it!