[FEATURE] prompt for module type as part of npm init #75
Replies: 10 comments
-
I'm concerned about users choosing "module", however, and unwittingly not being backwards compatible with older nodes and browsers. It seems like the first question Either way, adding "type: commonjs" by default seems like a great improvement. |
Beta Was this translation helpful? Give feedback.
-
Good point. Making sure to ask / present the prompt in an easily understandable way and the implications of the answer to that question, is definitely good to call out. In general, there is definitely a level of awareness to the broader community at large, and in a way this feature could be a good way to start spreading that awareness. Maybe it could include a link to learn more about what each |
Beta Was this translation helpful? Give feedback.
-
IMO, the first step is not even asking and just adding |
Beta Was this translation helpful? Give feedback.
-
Fair points re: prompt vs default. That said, (and I can go through I am also happy to rephrase (or maybe open a new one?) the RFC to remove prompt entirely and the behavior can be to just set the |
Beta Was this translation helpful? Give feedback.
-
Yes right now the only things included are also prompted for. Maybe it is fine to prompt and set the default to |
Beta Was this translation helpful? Give feedback.
-
I suppose one line of thinking here was that if education is needed / desired to help spread awareness around the community of this topic, this prompt could be a good way to start new packages off on the right step and also engage the community to be aware / informed of the options. I suppose it may come down to if the NodeJS community itself has a strong and compelling story itself to tell around this topic and what sort of narrative it feels should be spread across the ecosystem (say it loud, need to know, etc). Though I can understand wanting to refrain from jumping to one choice too soon, as it could have a negative effect as well. So it seems that although we all agree here on a default
(Or maybe there's a third option?) |
Beta Was this translation helpful? Give feedback.
-
I'm of the mind that the first pass at this should just be to set a default value. When you run
I'm not sure the default I'd be curious to know if most people run |
Beta Was this translation helpful? Give feedback.
-
I never use -y; its defaults are always incorrect for me (starting at 1.0.0 instead of 0.0.0 so i can’t bump the version to 1.0.0 in the release commit; defaulting the package name to the folder name which for me always ends in I think that |
Beta Was this translation helpful? Give feedback.
-
It seems then that if we want to be consistent with how things work currently, it should be that the user gets prompted. Unless we are looking to make an exception because of where the state of modules is in NodeJS? Would / could this set precedent for this to happen with other default values, and is that a precedent we would want to open the door to? It seems that there could be a whole other RFC to discuss if a choice presented to a user during |
Beta Was this translation helpful? Give feedback.
-
Looks like this has been (re) submitted as an RFC - #347 |
Beta Was this translation helpful? Give feedback.
-
What / Why
This would be helpful for the tooling / loader / JS ecosystem in terms of better understanding package contents by making sure this setting is always available (and not needing to know the assumed default workings of npm / nodejs / etc)
When
When a user runs
npm init
Where
NPM CLI
How
Current Behavior
By default,
npm init
(and accepting all defaults) creates a minimal package.json like thisExpected Behavior
After running
npm init
the user should be prompted to provide a module type, with the default being commonjsWho
References
Discussed during Node+JS Interactive 2019 Collab Summit during the ESM modules session.
Beta Was this translation helpful? Give feedback.
All reactions