You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is a common convention for build tools to be in devDependencies instead of dependencies. I have noticed that create-react-app generates a package.json with only dependencies, and I think the react-scripts dependency counts as a build and testing tool which can be moved to devDependencies. If this hasn't already been discussed and it's possible for us to try it, I can start a PR on the template generator.
Note that even though react-scripts generates production code, npm still considers it a build tool that is not necessary in production environments because it does not produce code that relies on native Node bindings in production. Users can still safely install devDependencies in production environments if they can't build outside of their production environment, though I feel this is uncommon with GitHub Pages and Travis being so popular.
If someone is planning on downloading and using your module in their program, then they probably don't want or need to download and build the external test or documentation framework that you use.
In this case, it's best to map these additional items in a devDependencies object.
These things will be installed when doing npm link or npm install from the root of a package, and can be managed like any other npm configuration param. See npm-config for more on the topic.
For build steps that are not platform-specific, such as compiling CoffeeScript or other languages to JavaScript, use the prepare script to do this, and make the required package a devDependency.
The text was updated successfully, but these errors were encountered:
It's been discussed numerous times before, see #2696.
TLDR: this solves issues for some users, and doesn't make any difference for other people. Those who don't like it can always move it to devDependencies themselves.
I don't think npm's advice is very relevant here. It is primarily concerning Node apps. CRA doesn't give you a Node app. From that perspective, all dependencies (including React) are "dev" dependencies because they're only necessary for the build: once you build the app, it has no deps at all. But putting react and react-dom in devDependencies will be just as confusing, and create those additional problems for some hosting providers. So instead we put them all in dependencies.
It is a common convention for build tools to be in
devDependencies
instead ofdependencies
. I have noticed thatcreate-react-app
generates apackage.json
with onlydependencies
, and I think thereact-scripts
dependency counts as a build and testing tool which can be moved todevDependencies
. If this hasn't already been discussed and it's possible for us to try it, I can start a PR on the template generator.Note that even though
react-scripts
generates production code, npm still considers it a build tool that is not necessary in production environments because it does not produce code that relies on native Node bindings in production. Users can still safely installdevDependencies
in production environments if they can't build outside of their production environment, though I feel this is uncommon with GitHub Pages and Travis being so popular.According to the npm docs for devDependencies:
The text was updated successfully, but these errors were encountered: