Running a custom script with a configured command (node location) that does not exist results in an "undefined" error without much information. Looking at the output one can gleam that the node version does not exist, but not from the actual notification text.
"~/.config/nvm/versions/node/v18.0.0/bin/node" does not exist.
shows:
The otuput console for frontmatter shows:
["INFO" - 18:11:19] Receiving message from webview to panel: custom-script
["INFO" - 18:11:19] Executing: ~/.config/nvm/versions/node/v18.0.0/bin/node /home/patrick/github.com/davidsneighbour/kollitsch.dev/assets/config/frontmatter/scripts/create-youtube-header-image.js "/home/patrick/github.com/davidsneighbour/kollitsch.dev" "/home/patrick/github.com/davidsneighbour/kollitsch.dev/content/blog/2022/music-to-program-to-8/index.md" '{"date":"2022-11-13T18:37:57+07:00","lastmod":"2022-11-13T18:44:15+07:00","title":"Music to program to","linkTitle":"PM8","tags":["programming-music","leenalchi","tok","100DaysToOffload"],"posttype":"music","resources":[{"src":"header.jpg","title":"Tiger is coming"}],"video":{"youtube":"LCZPF0eg9UA","artist":"leenalchi","title":"Tiger is coming"}}'
["ERROR" - 18:11:19] Front Matter: Generate social image for Youtube: undefined
["INFO" - 18:11:19] Front Matter: Generate social image for Youtube: Executed your custom script.
Running the script manually with the second line command results in:
bash: /home/patrick/.config/nvm/versions/node/v18.0.0/bin/node: No such file or directory
(due to some re-installing and moving around we are at v18.12.1 ;)
You could reproduce it using my repo at github.com/davidsneighbour/kollitsch.dev - run npm install, npm build and then open the workspace file open one of the "music to program to" posts in content/2022/. Click the custom script to retrieve the youtube image.
Latest Frontmatter (non-beta), latest VSCode.
Long story short, one of the following applies :)
feature: at some point Frontmatter should check, if the file in command and script exists and throw a readable error if not. I know computation time at program start is scarce (or when the configuration is reloaded), but that would be a good time to complain about this :)
bug: the custom script is tried, but fails. Frontmatter should show something readable instead of "undefined" (not sure how this works "behind the curtains")
**Describe the bug**
Running a custom script with a configured command (node location) that does not exist results in an "undefined" error without much information. Looking at the output one can gleam that the node version does not exist, but not from the actual notification text.
**To Reproduce**
```json
"frontMatter.custom.scripts": [
{
"title": "Retrieve Unsplash image",
"script": "./assets/config/frontmatter/scripts/retrieve-unsplash-header-image-info.js",
"command": "~/.config/nvm/versions/node/v18.0.0/bin/node"
}
],
```
`"~/.config/nvm/versions/node/v18.0.0/bin/node"` does not exist.
shows:

The otuput console for frontmatter shows:
```
["INFO" - 18:11:19] Receiving message from webview to panel: custom-script
["INFO" - 18:11:19] Executing: ~/.config/nvm/versions/node/v18.0.0/bin/node /home/patrick/github.com/davidsneighbour/kollitsch.dev/assets/config/frontmatter/scripts/create-youtube-header-image.js "/home/patrick/github.com/davidsneighbour/kollitsch.dev" "/home/patrick/github.com/davidsneighbour/kollitsch.dev/content/blog/2022/music-to-program-to-8/index.md" '{"date":"2022-11-13T18:37:57+07:00","lastmod":"2022-11-13T18:44:15+07:00","title":"Music to program to","linkTitle":"PM8","tags":["programming-music","leenalchi","tok","100DaysToOffload"],"posttype":"music","resources":[{"src":"header.jpg","title":"Tiger is coming"}],"video":{"youtube":"LCZPF0eg9UA","artist":"leenalchi","title":"Tiger is coming"}}'
["ERROR" - 18:11:19] Front Matter: Generate social image for Youtube: undefined
["INFO" - 18:11:19] Front Matter: Generate social image for Youtube: Executed your custom script.
```
Running the script manually with the second line command results in:
```
bash: /home/patrick/.config/nvm/versions/node/v18.0.0/bin/node: No such file or directory
```
(due to some re-installing and moving around we are at v18.12.1 ;)
You could reproduce it using my repo at github.com/davidsneighbour/kollitsch.dev - run `npm install`, `npm build` and then open the workspace file open one of the "music to program to" posts in `content/2022/`. Click the custom script to retrieve the youtube image.
Latest Frontmatter (non-beta), latest VSCode.
Long story short, one of the following applies :)
- feature: at some point Frontmatter should check, if the file in `command` and `script` exists and throw a readable error if not. I know computation time at program start is scarce (or when the configuration is reloaded), but that would be a good time to complain about this :)
- bug: the custom script is tried, but fails. Frontmatter should show something readable instead of "undefined" (not sure how this works "behind the curtains")
<!-- github-sync-id:1446894364 -->
Thanks, I found the issue, and will be updated to the real command error it returns. Example:
Thanks, I found the issue, and will be updated to the real command error it returns. Example:

<!-- github-comment-id:1313379411 -->
Running the sample script gives the same node not found error. Maybe its because it is running in a simple /bin/sh terminal which doesn't know anything about node:
constarguments=process.argv;if(arguments&&arguments.length>0){constworkspaceArg=arguments[2];// The workspace path
constfileArg=arguments[3];// The file path
constfrontMatterArg=arguments[4];// Front matter data
console.log(`NOTIFICATION SUCCESS?!`);}
Running the sample script gives the same `node` not found error. Maybe its because it is running in a simple `/bin/sh` terminal which doesn't know anything about node:
`/bin/sh: node: command not found`
`frontmatter.json`
```json
"frontMatter.custom.scripts": [
{
"id": "sample",
"title": "Sample",
"script": "./scripts/sample.js",
"command": "node"
}
]
```
`scripts/sample.js`
```js
const arguments = process.argv;
if (arguments && arguments.length > 0) {
const workspaceArg = arguments[2]; // The workspace path
const fileArg = arguments[3]; // The file path
const frontMatterArg = arguments[4]; // Front matter data
console.log(`NOTIFICATION SUCCESS?!`);
}
```
<!-- github-comment-id:1313472546 -->
@rshmhrj it depends on how your VS Code instance is configured. That is also why you can provide a path to your node executable.
@rshmhrj it depends on how your VS Code instance is configured. That is also why you can provide a path to your node executable.
<!-- github-comment-id:1313699558 -->
@davidsneighbour maybe try a full path to the executable instead of ~/.config/nvm/versions/node/v18.0.0/bin/node use /home/patrick/.config/nvm/versions/node/v18.0.0/bin/node
Hi @estruyf ,
Tested again by editing the `command` value and was successful:

When I run `which node`, the value is `/usr/local/bin/node`:
```json
"frontMatter.custom.scripts": [
{
"id": "sample",
"title": "Sample",
"script": "./scripts/sample.js",
"command": "/usr/local/bin/node"
}
]
```
@davidsneighbour maybe try a full path to the executable instead of `~/.config/nvm/versions/node/v18.0.0/bin/node` use `/home/patrick/.config/nvm/versions/node/v18.0.0/bin/node`
<!-- github-comment-id:1328194206 -->
The path works in both ways. My issue was that the current version was NOT 18.0.0 but later, and the interface didn't indicate it. Seems to be more verbose in beta now and is working when configured properly.
The path works in both ways. My issue was that the current version was NOT 18.0.0 but later, and the interface didn't indicate it. Seems to be more verbose in beta now and is working when configured properly.
<!-- github-comment-id:1328225649 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Describe the bug
Running a custom script with a configured command (node location) that does not exist results in an "undefined" error without much information. Looking at the output one can gleam that the node version does not exist, but not from the actual notification text.
To Reproduce
"~/.config/nvm/versions/node/v18.0.0/bin/node"does not exist.shows:
The otuput console for frontmatter shows:
Running the script manually with the second line command results in:
(due to some re-installing and moving around we are at v18.12.1 ;)
You could reproduce it using my repo at github.com/davidsneighbour/kollitsch.dev - run
npm install,npm buildand then open the workspace file open one of the "music to program to" posts incontent/2022/. Click the custom script to retrieve the youtube image.Latest Frontmatter (non-beta), latest VSCode.
Long story short, one of the following applies :)
commandandscriptexists and throw a readable error if not. I know computation time at program start is scarce (or when the configuration is reloaded), but that would be a good time to complain about this :)Thanks, I found the issue, and will be updated to the real command error it returns. Example:
Running the sample script gives the same
nodenot found error. Maybe its because it is running in a simple/bin/shterminal which doesn't know anything about node:/bin/sh: node: command not foundfrontmatter.jsonscripts/sample.js@rshmhrj it depends on how your VS Code instance is configured. That is also why you can provide a path to your node executable.
Hi @estruyf ,
Tested again by editing the
commandvalue and was successful:When I run
which node, the value is/usr/local/bin/node:@davidsneighbour maybe try a full path to the executable instead of
~/.config/nvm/versions/node/v18.0.0/bin/nodeuse/home/patrick/.config/nvm/versions/node/v18.0.0/bin/nodeThe path works in both ways. My issue was that the current version was NOT 18.0.0 but later, and the interface didn't indicate it. Seems to be more verbose in beta now and is working when configured properly.