functions-framework-nodejs
functions-framework-nodejs copied to clipboard
docs: Update debugging markdown
Hi, we were trying to debug cloud functions locally, using functions-framework. It seems that the doc is out of date, it doesn't work if you point to .bin folder
We were testing using:
- Windows 10
- node.js v18.12.1
- cmd console
This is the output we were receiving when we tried to debug it in the way it was documented.
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
←[90m at Object.compileFunction (node:vm:360:18)←[39m
←[90m at wrapSafe (node:internal/modules/cjs/loader:1088:15)←[39m
←[90m at Module._compile (node:internal/modules/cjs/loader:1123:27)←[39m
←[90m at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)←[39m
←[90m at Module.load (node:internal/modules/cjs/loader:1037:32)←[39m
←[90m at Module._load (node:internal/modules/cjs/loader:878:12)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)←[39m
←[90m at node:internal/main/run_main_module:23:47←[39m
Node.js v18.12.1
It's related to:
- #420
- #15 (in this one a lot of people were complaining about this error)
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!
-- conventional-commit-lint bot https://conventionalcommits.org/
Hi @garethgeorge, do you mind reviewing this?
I just tested and the debugging works fine as documented. Perhaps there was an issue with your npm install?
Can confirm that this is a problem when using pnpm specifically. I'm not sure if @tnovau was using pnpm though. I'm guessing it's because of how pnpm differs to npm when installing dependencies:
npm
ls -la node_modules/.bin | grep functions-framework
lrwxr-xr-x 1 xxx staff 54 May 1 15:50 functions-framework -> ../@google-cloud/functions-framework/build/src/main.js
lrwxr-xr-x 1 xxx staff 54 May 1 15:50 functions-framework-nodejs -> ../@google-cloud/functions-framework/build/src/main.js
pnpm
ls -la node_modules/.bin | grep functions-framework
-rwxr-xr-x 1 xxx staff 2784 May 1 15:58 functions-framework
-rwxr-xr-x 1 xxx staff 2784 May 1 15:58 functions-framework-nodejs
Note how npm (for node version v18.19.0) generates symbolically linked files for the executables in .bin whereas pnpm doesn't. Either way, the suggested change in this PR fixes the issue (for pnpm users at least).