# Referring to a specific module version in the function node?

**URL:** <https://discourse.nodered.org/t/referring-to-a-specific-module-version-in-the-function-node/76633>\
**Category:** General\
**Tags:** function-node\
**Created:** [16 March 2023 15:06 UTC](https://discourse.nodered.org/t/referring-to-a-specific-module-version-in-the-function-node/76633 "2023-03-16T15:06:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![DirkRodi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dirkrodi/32/77589_2.png) [@DirkRodi](https://discourse.nodered.org/u/DirkRodi)\
**Post date:** [16 March 2023 15:06 UTC](https://discourse.nodered.org/t/referring-to-a-specific-module-version-in-the-function-node/76633/1 "2023-03-16T15:06:45Z")

</div>

Is there a way to reference a specific module version when adding modules to a function node?

I tried with a module name like this "mymodule@0.1.0" and the logs showed that this specific version has been installed successfully, but right after the logs says:

```auto
 [error] [function:a6b143fb515da793] Error: Cannot find module 'mymodule@0.1.0'
Require stack:
- C:\...\node_modules\mymodule@0.1.0

```

Regards,  
Dirk

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 March 2023 15:33 UTC](https://discourse.nodered.org/t/referring-to-a-specific-module-version-in-the-function-node/76633/2 "2023-03-16T15:33:09Z")

</div>

You can't do it in a function node, but you can do it in package.json

If you look there after you have installed the module you will see it there, along with a definition of valid versions. Make sure it stipulates only the correct version and it will always be that version. Provided you do not install a different version instead.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [16 March 2023 17:27 UTC](https://discourse.nodered.org/t/referring-to-a-specific-module-version-in-the-function-node/76633/3 "2023-03-16T17:27:55Z")

</div>

> [@Colin](#):
>
> You can't do it in a function node, but you can do it in package.json

Actually you can as I recently discovered. Try it out with the dummy package, try adding `aaa@0.0.1` and you will see that it installs that version instead of the latest 0.0.2.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/5/c54f87a155f398c33a76c836d7d6f1612fb7b162.png)

```auto
  "dependencies": {
    "aaa": "^0.0.1",
    "read-excel-file": "^5.6.1"
  },

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 March 2023 17:30 UTC](https://discourse.nodered.org/t/referring-to-a-specific-module-version-in-the-function-node/76633/4 "2023-03-16T17:30:34Z")

</div>

Well, you live and learn.

---

<div class="post-metadata">

**Author:** ![DirkRodi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dirkrodi/32/77589_2.png) [@DirkRodi](https://discourse.nodered.org/u/DirkRodi)\
**Post date:** [20 March 2023 09:43 UTC](https://discourse.nodered.org/t/referring-to-a-specific-module-version-in-the-function-node/76633/5 "2023-03-20T09:43:08Z")

</div>

Thanks for your answers!

This is exactly what i tried, adding the module name incl. the version qualifier. It installs the specified version and I see it in the dependencies, but the Node-Red log prompts with "`Error: Cannot find module 'mymodule@0.1.0'`".  
So, referencing a specific in the "Modules" list does not fully work. It installs the modules in the specified version, but it can't load it, because it look for a module name 'mymodule@0.1.0' although it is installed with name 'mymodule'.

My workaround: I will not use 'Modules' feature in the function node, will install the module with a classic "npm install mymodule@0.1.0" in my docker initialization, make it a global requirement in the 'settings.js' and get it via '`const myMod = global.get("mymodule");`'

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 March 2023 09:47 UTC](https://discourse.nodered.org/t/referring-to-a-specific-module-version-in-the-function-node/76633/6 "2023-03-20T09:47:29Z")

</div>

Thanks for the update. I think that is actually a bug so you might want to raise an issue against the node-red repo.

Since you _can_ install with a version modifier, node-red should really be able to cope with that or should reject the install. I know that on uibuilder, which has a similar interface for loading npm modules that are mounted as web endpoints, it does cope with version modifiers.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [19 May 2023 09:47 UTC](https://discourse.nodered.org/t/referring-to-a-specific-module-version-in-the-function-node/76633/7 "2023-05-19T09:47:40Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
