# Cannot install module via HTTP Admin API

**URL:** <https://discourse.nodered.org/t/cannot-install-module-via-http-admin-api/20335>\
**Category:** General\
**Created:** [14 January 2020 20:28 UTC](https://discourse.nodered.org/t/cannot-install-module-via-http-admin-api/20335 "2020-01-14T20:28:36Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![brunoshine](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/brunoshine/32/16154_2.png) [@brunoshine](https://discourse.nodered.org/u/brunoshine)\
**Post date:** [14 January 2020 20:28 UTC](https://discourse.nodered.org/t/cannot-install-module-via-http-admin-api/20335/1 "2020-01-14T20:28:36Z")

</div>

Hi all,

I'm trying to install a custom module via the HTTP Admin API but with no success as I keep getting:

```auto
{
  "code": "MODULE_NOT_FOUND",
  "message": "Cannot find module '[ABSOLUTE PATH PATH TO MY MODULE DIR]'"
}

```

On node-red logs shows:

```auto
[0] 14 Jan 20:27:49 - [info] Installing module: [ABSOLUTE PATH PATH TO MY MODULE DIR], version: latest
[0] 14 Jan 20:27:49 - [debug] npm.cmd install --no-audit --no-update-notifier --save --save-prefix="~" --production [ABSOLUTE PATH PATH TO MY MODULE DIR]
[0] 14 Jan 20:27:51 - [debug] [out] + teste@0.0.1
[0] 14 Jan 20:27:51 - [debug] [out] updated 1 package in 0.12s
[0] 14 Jan 20:27:51 - [debug] rc=0
[0] 14 Jan 20:27:51 - [info] Installed module: [ABSOLUTE PATH PATH TO MY MODULE DIR]

```

I'm executing:

```auto
POST http://{{host}}/red/nodes
content-type: application/json
Accept: application/json
{
    "module":"[ABSOLUTE PATH PATH TO MY MODULE DIR]"
}

```

If I run the `npm install [ABSOLUTE PATH PATH TO MY MODULE DIR]` it works.

Any thoughts?  
Thanks

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [14 January 2020 21:00 UTC](https://discourse.nodered.org/t/cannot-install-module-via-http-admin-api/20335/2 "2020-01-14T21:00:06Z")

</div>

Are you using windows? The fact it says `npm.cmd` makes me thing you are.

Can you share the actual path you are using? I wonder if there's a windows path separator issue here where we are failing to detect the path properly.

The log output says it has installed the module. Can you have a look in `.node-red/node_modules` to see if the module has been installed?

---

<div class="post-metadata">

**Author:** ![brunoshine](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/brunoshine/32/16154_2.png) [@brunoshine](https://discourse.nodered.org/u/brunoshine)\
**Post date:** [15 January 2020 08:43 UTC](https://discourse.nodered.org/t/cannot-install-module-via-http-admin-api/20335/3 "2020-01-15T08:43:36Z")

</div>

Hi Nick, thanks for the quick reply.

Yes I'm running on Windows. I'm also running node-red in "embedded mode".

The HTTP request is:

```auto
POST http://{{host}}/red/nodes
content-type: application/json
Accept: application/json
{
    "module":"C:\\@Work\\00_projects\\pxp\\src\\temp\\.gen\\teste"
}

```

node-red logs:

```auto
[0] 15 Jan 08:34:08 - [info] Installing module: C:\@Work\00_projects\pxp\src\temp\.gen\teste, version: latest[0] 15 Jan 08:34:08 - [debug] npm.cmd install --no-audit --no-update-notifier --save --save-prefix="~" --production C:\@Work\00_projects\pxp\src\temp\.gen\teste
[0] 15 Jan 08:34:10 - [debug] [out] + teste@0.0.1
[0] 15 Jan 08:34:10 - [debug] [out] added 2 packages from 2 contributors in 0.09s
[0] 15 Jan 08:34:10 - [debug] rc=0
[0] 15 Jan 08:34:10 - [info] Installed module: C:\@Work\00_projects\pxp\src\temp\.gen\teste

```

And the `.node-red/node_modules`:  
 ![Code_ErKN43Z7EJ](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/c/4cda2a36e64eeb4df97befedda3ddc9533b5e02a.png)

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![brunoshine](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/brunoshine/32/16154_2.png) [@brunoshine](https://discourse.nodered.org/u/brunoshine)\
**Post date:** [20 January 2020 09:48 UTC](https://discourse.nodered.org/t/cannot-install-module-via-http-admin-api/20335/4 "2020-01-20T09:48:37Z")

</div>

Hi @knolleary,

any thoughts on this?

Thanks.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [20 January 2020 09:51 UTC](https://discourse.nodered.org/t/cannot-install-module-via-http-admin-api/20335/5 "2020-01-20T09:51:59Z")

</div>

Hi @brunoshine

I haven't been able to reproduce locally, but I suspect it may be an issue with our path detection on Windows.

I haven't had a chance to dust off my Windows VM to test that theory.

Please can you raise an issue so we don't forget about it.

Nick

---

<div class="post-metadata">

**Author:** ![brunoshine](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/brunoshine/32/16154_2.png) [@brunoshine](https://discourse.nodered.org/u/brunoshine)\
**Post date:** [23 January 2020 00:48 UTC](https://discourse.nodered.org/t/cannot-install-module-via-http-admin-api/20335/6 "2020-01-23T00:48:28Z")

</div>

Hi @knolleary,

i've tried on a Mac and got the same error:

```auto
POST http://{{host}}/red/nodes
content-type: application/json
Accept: application/json

{
    "module":"/Users/bfigueir/@work/00_projects/pxp/src/temp/.gen/teste"
}

```

```auto
23 Jan 00:37:41 - [info] Installed module: teste
[0] 23 Jan 00:38:57 - [info] Installing module: teste, version: latest
[0] 23 Jan 00:38:57 - [trace] npm["install","--no-audit","--no-update-notifier","--save","--save-prefix=\"~\"","--production","/Users/bfigueir/@work/00_projects/pxp/src/temp/.gen/teste"]
[0] 23 Jan 00:38:57 - [debug] npm install --no-audit --no-update-notifier --save --save-prefix="~" --production /Users/bfigueir/@work/00_projects/pxp/src/temp/.gen/teste
[0] 23 Jan 00:38:57 - [debug] [out] + teste@1.0.0
[0] 23 Jan 00:38:57 - [debug] [out] updated 1 package in 0.107s
[0] 23 Jan 00:38:58 - [debug] rc=0
[0] 23 Jan 00:38:58 - [info] Installed module: teste

```

```auto
HTTP/1.1 400 Bad Request
X-Powered-By: Express
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=utf-8
Content-Length: 66
ETag: W/"42-pdDQMPIpR0JgSB/UW4tjdbiDs18"
Date: Thu, 23 Jan 2020 00:38:58 GMT
Connection: close

{
  "code": "MODULE_NOT_FOUND",
  "message": "Cannot find module 'teste'"
}

```

on that folder i've got a package.json file:

```auto

{
    "name": "teste",
    "version": "1.0.0",
    "description": "",
    "node-red":{
        "nodes":{
        "teste":"teste.js"
        }
    }
}

```

Thanks!

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [23 January 2020 11:40 UTC](https://discourse.nodered.org/t/cannot-install-module-via-http-admin-api/20335/7 "2020-01-23T11:40:38Z")

</div>

Hi @brunoshine

I still can't reproduce this.

What versions of `npm` and `node.js` are you using?

After the install, what does its entry in the `dependencies` section of `~/.node-red/package.json` look like?

---

<div class="post-metadata">

**Author:** ![brunoshine](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/brunoshine/32/16154_2.png) [@brunoshine](https://discourse.nodered.org/u/brunoshine)\
**Post date:** [23 January 2020 19:00 UTC](https://discourse.nodered.org/t/cannot-install-module-via-http-admin-api/20335/8 "2020-01-23T19:00:39Z")

</div>

Hi @knolleary

npm: 6.9.0  
node: v10.16.0

```auto
{
    "name": "node-red-project",
    "description": "A Node-RED Project",
    "version": "0.0.1",
    "private": true,
    "dependencies": {
        "teste": "file:../../temp/.gen/teste"
    }
}

```

The `~/.node-red/node_modules` contains the `teste` package and its files:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/a/1a7b513f5821244a8717f684d64a0a83a6869e82.png)

If I restart the app, the module isn't loaded and does not show on the palette.

Thanks.

---

<div class="post-metadata">

**Author:** ![brunoshine](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/brunoshine/32/16154_2.png) [@brunoshine](https://discourse.nodered.org/u/brunoshine)\
**Post date:** [23 January 2020 19:07 UTC](https://discourse.nodered.org/t/cannot-install-module-via-http-admin-api/20335/9 "2020-01-23T19:07:46Z")

</div>

If I copy the teste folder to the `~/.nodered/nodes` folder, and restart the app, the node gets loaded and starts showing on the palette.

Is there any way to tell node-red to reload the nodes palette without the need to restart the app?

thanks.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [23 January 2020 20:08 UTC](https://discourse.nodered.org/t/cannot-install-module-via-http-admin-api/20335/10 "2020-01-23T20:08:51Z")

</div>

@brunoshine if a module is installed in `~/.node-red/node_modules` then Node-RED should be loading it on startup. The fact it isn't is strange and also explains why you get the error - it installs the module then fails to find where it has been installed. There must be something else about your setup to explain this.

How are you running Node-RED? Is this a 'normal' install or are you doing something non-default with the configuration?

---

<div class="post-metadata">

**Author:** ![brunoshine](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/brunoshine/32/16154_2.png) [@brunoshine](https://discourse.nodered.org/u/brunoshine)\
**Post date:** [24 January 2020 09:51 UTC](https://discourse.nodered.org/t/cannot-install-module-via-http-admin-api/20335/11 "2020-01-24T09:51:22Z")

</div>

Hi @knolleary,

so I managed it to start working. I'm running node-red in a embeded mode and made some configurations changes, one being the `userDir` setting where I was pointing to a relative path `./src/node-red/.nodered/` loaded from environment variable. After some digging around the node-red code (debugging) I saw that on the filesystem.js node-red was trying to `require` the package it was not founding it. I then changed the `userDir` to a absolutePath and now its working.

Thanks for the guidance and all the help. I'll try to dig up a bit more on why the relative path is not working.

Once again thanks 🙂

---

<div class="post-metadata">

**Author:** ![jaime.villasenor](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jaime.villasenor/32/45977_2.png) [@jaime.villasenor](https://discourse.nodered.org/u/jaime.villasenor)\
**Post date:** [15 September 2020 15:44 UTC](https://discourse.nodered.org/t/cannot-install-module-via-http-admin-api/20335/12 "2020-09-15T15:44:17Z")

</div>

I am getting the same response in Windows only, I also the installed node is being added as dependency in node\_red\_config/package.json and the symlink is been created in node\_red\_config/node\_modules. The node is only available in HTTP GET /nodes after I have restarted the server. Is there any workaround to this issue?  
Version  
node -\> v10.16.0  
npm -\> 6.9.0  
node-red -\> 0.20.8

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [15 September 2020 16:04 UTC](https://discourse.nodered.org/t/cannot-install-module-via-http-admin-api/20335/13 "2020-09-15T16:04:35Z")

</div>

To avoid splitting the discussion, I've replied to your Stack Overflow question - [https://stackoverflow.com/questions/63905066/code-module-not-found-was-returned-when-a-node-red-node-is-installed-using-the-h](https://stackoverflow.com/questions/63905066/code-module-not-found-was-returned-when-a-node-red-node-is-installed-using-the-h)
