Skip to content

Cannot find name 'Buffer'. Do you need to install type definitions for node? #587

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

Closed
ejizba opened this issue May 27, 2022 · 2 comments
Closed

Comments

@ejizba
Copy link
Contributor

ejizba commented May 27, 2022

The recent release of the types package references Buffer which is defined in @types/node. Without that package, users will see an error like this:
image

This is a somewhat common problem in the types world and there's no good solution. Fortunately the error is pretty self explanatory and most users should know how to fix. That being said, it would be nice if our types worked "out of the box" and so filing the issue for further discussion. A few ideas off the top of my head:

  1. Remove the reference to Buffer in the types. I think this is a short term fix, though - because as we continue to make improvements to our types we will want to reference more and more node types
  2. Add @types/node as a dependency of @azure/functions. I don't think we can do this, because we support multiple versions of node and we don't want to hard-code users to the wrong version
  3. Make sure project templates have @types/node in the package.json. This could work, but puts the burden on the templates to pick the right version of node instead of us
@ejizba
Copy link
Contributor Author

ejizba commented Jun 7, 2022

Decided to go with option 3. For the version, we will choose the latest version of Node corresponding to the user's version of the Functions runtime. There's a chance users are actually on an earlier version of Node, but the risk of that causing problems is minimal compared to the benefit of the template working out of the box. Since this is set in the template (as opposed to option 2), users can easily change the version themselves.

VS Code PR:
microsoft/vscode-azurefunctions#3212

Core tools PRs:
Azure/azure-functions-core-tools#3068
Azure/azure-functions-core-tools#3069

cc @davidmrdavid @hossam-nasr since we talked about this in standup today

@ejizba
Copy link
Contributor Author

ejizba commented Jul 6, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant