# Help with TOC Plugin Tutorial?

**URL:** <https://discourse.joplinapp.org/t/help-with-toc-plugin-tutorial/23488>\
**Category:** Plugins\
**Created:** [3 February 2022 16:31 UTC](https://discourse.joplinapp.org/t/help-with-toc-plugin-tutorial/23488 "2022-02-03T16:31:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tartaglia](https://avatars.discourse-cdn.com/v4/letter/t/a88e4f/32.png) [@Tartaglia](https://discourse.joplinapp.org/u/Tartaglia)\
**Post date:** [3 February 2022 16:31 UTC](https://discourse.joplinapp.org/t/help-with-toc-plugin-tutorial/23488/1 "2022-02-03T16:31:30Z")

</div>

I am trying to familiarize myself with writing Joplin plugins. I have successfully gone through the steps of the "Getting started with plugin development" guide (sorry I only get 1 link as a new user) which creates a working "Hello world" program.

I am now trying to complete the more in-depth tutorial here: "Creating a table of content plugin" and things have gone smoothly until this section [Getting the note sections and slugs](https://joplinapp.org/api/tutorials/toc_plugin/#getting-the-note-sections-and-slugs). Here when I compile (npm run dist) this code (if I use the ampersand symbol it won't let me post, in the code below AT stands for ampersand):

```auto
const uslug = require(' AT joplin/fork-uslug');

let slugs = {};

function headerSlug(headerText) {
	const s = uslug(headerText);
	let num = slugs[s] ? slugs[s] : 1;
	const output = [s];
	if (num > 1) output.push(num);
	slugs[s] = num + 1;
	return output.join('-');
}

```

I get the following error in the command console:

```auto
ERROR in ./src/index.ts
    Module not found: Error: Can't resolve 'AT joplin/fork-uslug' in 'C:\Joplin\plugin development\Test001\src'
     @ ./src/index.ts 76:14-43

```

If I replace the line "const uslug = require(' AT joplin/fork-uslug');" with "const uslug = joplin.require(' AT joplin/fork-uslug');" the plugin compiles, but when I run it in joplin I get the following error in Joplin's console:

```auto
plugin_index.js:61 Uncaught Error: Module not found: AT joplin/fork-uslug
    at target (plugin_index.js:61)
    at newTarget (C:\Joplin\resources\app.asar\vendor\lib\ AT joplin\lib\services\plugins\sandboxProxy.js:21)
    at Object.handler.apply (C:\Joplin\resources\app.asar\vendor\lib\ AT joplin\lib\services\plugins\sandboxProxy.js:35)
    at Object.<anonymous> (plugin_ThisIsATestPlugin.js:1)
    at n (plugin_ThisIsATestPlugin.js:1)
    at plugin_ThisIsATestPlugin.js:1
    at plugin_ThisIsATestPlugin.js:1

```

From googling it looks like there are a few folks having issues with uslug recently but I am a bit out of my depth. I'm not attached to the uslug package really and would be fine proceeding without it. I tried replacing the variable "uslug" with a constant but I'm out of my comfort zone and don't think I used the correct data type -- so that threw more errors.

If anyone knows of a quick fix for these errors let me know. Or if you see a quick way for me to proceed with the tutorial? (Like a suitable constant to replace uslug with?) Much obliged!

---

<div class="post-metadata">

**Author:** ![JPQuan37](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/jpquan37/32/13170_2.png) [@JPQuan37](https://discourse.joplinapp.org/u/JPQuan37)\
**Post date:** [18 March 2022 07:12 UTC](https://discourse.joplinapp.org/t/help-with-toc-plugin-tutorial/23488/2 "2022-03-18T07:12:29Z")

</div>

Hi! I went in the same issue and I solved it by using

> const uslug = require('uslug');

instead of

> const uslug = require('(AT)joplin/fork-uslug');
