No package.json in ~/.node-red/ How to create?

468 views
Skip to first unread message

Jéan Roux

unread,
Apr 20, 2017, 5:59:03 PM4/20/17
to Node-RED
Hi Julian, for some reason my install does not have a ~/.node-red/package.json file, and that causes problems. I followed your advise 'how can I make re-intallation of nodes easier' on the cookbook github wiki, here How can I make reinstallation of nodes easier, which is also the same advise out on the web for this problem. 1st ran this command, 

cd ~/.node-red
npm init -y


But then I get:
npm ERR! Invalid name: ".node-red"

So, I still do not have a package.json, with all kinds of issues when you want to add / remove nodes. Any advise?

Julian Knight

unread,
Apr 21, 2017, 3:49:07 PM4/21/17
to Node-RED
OK, so what platform are you on?

If you are on Windows, CMD prompt doesn't have ~ defined. If you are Using Windows 10, switch to PowerShell which does have it defined. Otherwise, mentally translate ~ into %USERPROFILE%

If that is not the problem, we need to understand how you installed Node-RED and whether you changed the default userDir.

Nick O'Leary

unread,
Apr 21, 2017, 4:01:51 PM4/21/17
to Node-RED Mailing List
The problem is the -y used in the npm init command - nothing to do with platform.

When you run "npm init" it asks a bunch of questions to get some values into the package.json file it will create. The default value it suggests for the name field is the name of the directory you are running the command in - in this instance, .node-red. Using the -y option is a shortcut to accept all default values. As per the error message, .node-red is not a valid name for an npm module so the command fails.

The fix is simply not to use the -y argument and, when it suggests the .node-red value for the 'name' field, change it to something else like 'my-node-red-module'.

Nick

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/868aea9f-3e07-4499-84e4-0ed413e1e202%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Julian Knight

unread,
Apr 21, 2017, 4:44:57 PM4/21/17
to Node-RED
Ah, good spot. Need to amend that note in the WIKI.


On Friday, 21 April 2017 21:01:51 UTC+1, Nick O'Leary wrote:
The problem is the -y used in the npm init command - nothing to do with platform.

When you run "npm init" it asks a bunch of questions to get some values into the package.json file it will create. The default value it suggests for the name field is the name of the directory you are running the command in - in this instance, .node-red. Using the -y option is a shortcut to accept all default values. As per the error message, .node-red is not a valid name for an npm module so the command fails.

The fix is simply not to use the -y argument and, when it suggests the .node-red value for the 'name' field, change it to something else like 'my-node-red-module'.

Nick
On 21 April 2017 at 20:49, Julian Knight <j.kni...@gmail.com> wrote:
OK, so what platform are you on?

If you are on Windows, CMD prompt doesn't have ~ defined. If you are Using Windows 10, switch to PowerShell which does have it defined. Otherwise, mentally translate ~ into %USERPROFILE%

If that is not the problem, we need to understand how you installed Node-RED and whether you changed the default userDir.

On Thursday, 20 April 2017 22:59:03 UTC+1, Jéan Roux wrote:
Hi Julian, for some reason my install does not have a ~/.node-red/package.json file, and that causes problems. I followed your advise 'how can I make re-intallation of nodes easier' on the cookbook github wiki, here How can I make reinstallation of nodes easier, which is also the same advise out on the web for this problem. 1st ran this command, 

cd ~/.node-red
npm init -y


But then I get:
npm ERR! Invalid name: ".node-red"

So, I still do not have a package.json, with all kinds of issues when you want to add / remove nodes. Any advise?

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Jéan Roux

unread,
Apr 24, 2017, 1:43:16 PM4/24/17
to Node-RED
Julian, I am on Pi, Nick I created the package.json with npm init. Will now see if all behave better. Thank you !

Dave C-J

unread,
Apr 24, 2017, 1:57:40 PM4/24/17
to node...@googlegroups.com
So far what I have observed is that it won't then complain about not having one when you install nodes (warn messages). But unless you go in and edit it to relax the versions specified, it still won't then upgrade them. So yes it helps get back to where you are/were but not the total answer. YMMV.

Julian Knight

unread,
Apr 25, 2017, 8:09:02 AM4/25/17
to Node-RED
Well that's down to the way npm works and the way people use version numbers isn't it? I think the default is "^2.3.1" or whatever which will get npm install to load anything from 2.3.1 to 2.n.n (e.g. not 3.0.0). But it wont do that for anything that is <1.0.0 because the assumption is that breaking changes will happen only on major version number changes for "live" code (1.0.0+) but will happen on minor version number changes for pre-release code. So "^0.3.2" would load anything from 0.3.2 to 0.3.n (e.g. not 0.4.0)

Dave C-J

unread,
Apr 25, 2017, 8:12:11 AM4/25/17
to node...@googlegroups.com
yes indeed it is... BUT the point being that the automatically generated package.json file doesn't have any of the ^ or ~ modifiers to relax the constraints so by default it pins nodes to the exact version you installed. (so npm update ... won't)

Julian Knight

unread,
Apr 25, 2017, 8:31:47 AM4/25/17
to Node-RED
Ah, I see - I learned something new! Again!! Don't think I've ever done it that way round so I'd never noticed it did that.

Dave C-J

unread,
Apr 25, 2017, 8:56:44 AM4/25/17
to node...@googlegroups.com
though once you have the file and do an npm install --save of a new node... doesn't it just add it for you ? I thought that was the way you were advocating doing it ?

Jéan Roux

unread,
Apr 25, 2017, 9:46:06 AM4/25/17
to node...@googlegroups.com
Okay, I am not sure I have followed this to the end....

So, if you do not have a package.json, 
  • you can create one with running npm init (not with -y), do not use the default, which is the directory, i.e. node-red, as it cannot accept a '.', name anytung, something like 'MyNodeRedModules' will work, all others just accept the defaults.
  • Then, you edit the created package.json, as the created one will not allow upgrades of the packages,
  • do this by ...... ????? ^ ....
Julian, maybe you could use this to update your cookbook on how I can make the reinstallation easier .... ?


But, I still have broken system, si I am interested in the editing part of the package.json .....

Thanks all.


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/uee8qP5lFx0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Nick O'Leary

unread,
Apr 25, 2017, 9:50:46 AM4/25/17
to Node-RED Mailing List
My advice:

1. it is good to have a package.json as it is a record of exactly what you have installed. The next version of NR will maintain one for you if you use the 'manage palette' feature.

2. the "npm outdated" command will tell you if there are newer versions of any modules available.

3. on a case-by-case basis (as I would not recommend blindly updating nodes without at least a cursory check over what has changed), run `npm install node...@1.2.3 --save` to install the node at the specific version you want and automatically update the package.json file to match

Nick

You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Jéan Roux

unread,
Apr 25, 2017, 12:03:27 PM4/25/17
to node...@googlegroups.com

Julian Knight

unread,
Apr 25, 2017, 3:50:20 PM4/25/17
to Node-RED
Yes, I'm updating now. I was going to raise an issue against npm init but when I saw that npm currently has 2,949 open issues, I decided not to bother!!

Interestingly, if you use "yarn init -y" (https://yarnpkg.com/lang/en/) - it does work even in a folder with a leading dot. Though it does retain the leading dot in the module name - I can't find anything that says you cannot use a module name with a leading dot but I don't suppose it is good practice. Not that it really matters in this case since we will never be using the module name publicly.

Anyway, as I say, I'm updating the WIKI entry.


On Tuesday, 25 April 2017 14:46:06 UTC+1, Jéan Roux wrote:
Okay, I am not sure I have followed this to the end....

So, if you do not have a package.json, 
  • you can create one with running npm init (not with -y), do not use the default, which is the directory, i.e. node-red, as it cannot accept a '.', name anytung, something like 'MyNodeRedModules' will work, all others just accept the defaults.
  • Then, you edit the created package.json, as the created one will not allow upgrades of the packages,
  • do this by ...... ????? ^ ....
Julian, maybe you could use this to update your cookbook on how I can make the reinstallation easier .... ?


But, I still have broken system, si I am interested in the editing part of the package.json .....

Thanks all.

On 25 April 2017 at 14:31, Julian Knight <j.kni...@gmail.com> wrote:
Ah, I see - I learned something new! Again!! Don't think I've ever done it that way round so I'd never noticed it did that.

On Tuesday, 25 April 2017 13:12:11 UTC+1, Dave C-J wrote:
yes indeed it is... BUT the point being that the automatically generated package.json file doesn't have any of the ^ or ~ modifiers to relax the constraints so by default it pins nodes to the exact version you installed. (so npm update ... won't)

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/uee8qP5lFx0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.

Jéan Roux

unread,
Apr 25, 2017, 3:59:30 PM4/25/17
to node...@googlegroups.com
Thanks Julian !

To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Julian Knight

unread,
Apr 25, 2017, 4:06:34 PM4/25/17
to Node-RED
Updated. I've also clarified some points on semver ranges and using ~ on Windows.
Thanks Julian !

Reply all
Reply to author
Forward
Message has been deleted
0 new messages