# Node with text input not installing

**URL:** <https://discourse.nodered.org/t/node-with-text-input-not-installing/44290>\
**Category:** Developing Nodes\
**Created:** [16 April 2021 16:31 UTC](https://discourse.nodered.org/t/node-with-text-input-not-installing/44290 "2021-04-16T16:31:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnnyPicnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johnnypicnic/32/34787_2.png) [@JohnnyPicnic](https://discourse.nodered.org/u/JohnnyPicnic)\
**Post date:** [16 April 2021 16:31 UTC](https://discourse.nodered.org/t/node-with-text-input-not-installing/44290/1 "2021-04-16T16:31:07Z")

</div>

I'm trying to create a node that simply takes a text input (phone number) and outputs it as msg.number. I can't seem to get the node to show up in Node-Red.  
It says it installed successfully. I'm a noob so it's quite possible there are many things wrong with this.

```auto
+ node-red-contrib-phone-number@1.0.0
added 1 package and audited 133 packages in 41.445s

```

js file

```auto
module.exports = function(RED) {
    function Phone-NumberNode(config) {
        RED.nodes.createNode(this,config);
        var node = this;
        node.on('input', function(msg) {
            msg.number = n.number;
            node.send(msg);
        });
    }
    RED.nodes.registerType("phone-number",Phone-NumberNode);
}

```

html file

```auto
<script type="text/javascript">
    RED.nodes.registerType('phone-number',{
        category: 'function',
        color: '#a6bbcf',
        defaults: {
            name: {value:"phone-number"}
        },
        inputs:1,
        outputs:1,
        icon: "",
        label: function() {
            return this.name||"phone-number";
        }
    });
</script>
<script type="text/x-red" data-template-name="phone-number">
    <div class="form-row">
        <label for="node-input-name"><i class="icon-tag"></i>Name</label>
        <input type="text" id="node-input-name" placeholder="Name">
    </div>
    <div class="form-row">
        <label for="node-input-number"><i class="icon-tag"></i>Number</label>
        <input type="text" id="node-input-number" placeholder="17801234567">
    </div>
</script>
<type="text/x-red" data-help-name="charcount">
    <p>Enter Phone Number</p>
</script>

```

package.json

```auto
{
  "name": "node-red-contrib-phone-number",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "node-red" : {
        "nodes": {
            "phone-number": "phone-number.js"
        }
    }
}

```

---

<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:** [16 April 2021 16:41 UTC](https://discourse.nodered.org/t/node-with-text-input-not-installing/44290/2 "2021-04-16T16:41:07Z")

</div>

What directory were you in when you ran the `npm install`?

Did you restart Node-RED after installing it?

Does the Node-RED log show any errors related to your node on startup?

Node-RED logs the user directory it is using on startup - that is the directory you should install the node in.

---

<div class="post-metadata">

**Author:** ![JohnnyPicnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johnnypicnic/32/34787_2.png) [@JohnnyPicnic](https://discourse.nodered.org/u/JohnnyPicnic)\
**Post date:** [16 April 2021 16:41 UTC](https://discourse.nodered.org/t/node-with-text-input-not-installing/44290/3 "2021-04-16T16:41:59Z")

</div>

Directory was ./node-red  
No errors

---

<div class="post-metadata">

**Author:** ![JohnnyPicnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johnnypicnic/32/34787_2.png) [@JohnnyPicnic](https://discourse.nodered.org/u/JohnnyPicnic)\
**Post date:** [16 April 2021 16:54 UTC](https://discourse.nodered.org/t/node-with-text-input-not-installing/44290/4 "2021-04-16T16:54:12Z")

</div>

Found the error in node-red startup  
`16 Apr 17:53:17 - [warn] [node-red-contrib-phone-number/phone-number] SyntaxError: Unexpected token '-' (line:2)`

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 April 2021 17:01 UTC](https://discourse.nodered.org/t/node-with-text-input-not-installing/44290/5 "2021-04-16T17:01:05Z")

</div>

> [@JohnnyPicnic](#):
>
> `function Phone-NumberNode(config)`

I'm sure you have now spotted the issue. However, are you using a proper editor like VSCODE? It would have highlighted this issue well before you attempted to install it.

---

<div class="post-metadata">

**Author:** ![JohnnyPicnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johnnypicnic/32/34787_2.png) [@JohnnyPicnic](https://discourse.nodered.org/u/JohnnyPicnic)\
**Post date:** [16 April 2021 17:02 UTC](https://discourse.nodered.org/t/node-with-text-input-not-installing/44290/6 "2021-04-16T17:02:04Z")

</div>

Thanks, I did see that and got it to install

Could you point me in the right direction for referencing my number input in the javascript function?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 April 2021 17:11 UTC](https://discourse.nodered.org/t/node-with-text-input-not-installing/44290/7 "2021-04-16T17:11:02Z")

</div>

> [@JohnnyPicnic](#):
>
> Could you point me in the right direction for referencing my number input in the javascript function?

Your function is ok. You are missing the default for your variable...

> [@JohnnyPicnic](#):
>
> ```auto
> defaults: {
> name: {value:"phone-number"}
> },
> 
> ```

Read the docs on creating your first node.

---

<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:** [15 June 2021 17:11 UTC](https://discourse.nodered.org/t/node-with-text-input-not-installing/44290/8 "2021-06-15T17:11:07Z")

</div>

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