依赖项部分中的create-react-app install devDepencies [英] create-react-app install devDepencies in dependencies section

查看:122
本文介绍了依赖项部分中的create-react-app install devDepencies的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 create-react-app 创建新项目并运行纱线弹出之后。

After creating a new project with create-react-app and running yarn eject.

package.json的依赖项部分如下:

The dependencies section of my package.json looks like this:

  "dependencies": {
    "autoprefixer": "7.1.1",
    "babel-core": "6.25.0",
    "babel-eslint": "7.2.3",
    "babel-jest": "20.0.3",
    "babel-loader": "7.0.0",
    "babel-preset-react-app": "^3.0.1",
    "babel-runtime": "6.23.0",
    etc.

我会说这些都是 devDependencies 为什么将create-react-app放在这里?

I would say these are all devDependencies why has create-react-app placed them here?

推荐答案

这是对最新版本之一的有意更改。

This is an intentional change in one of the latest versions.

对于产生静态捆绑包的前端应用程序,此区别是任意的。从技术上讲,您不需要服务器上的所有依赖项,甚至不需要运行时的依赖。因此,按照这种逻辑,即使 react 也可能被视为开发依赖项。

The distinction is pretty arbitrary for front-end apps that produce static bundles. Technically you don't need any of these dependencies on the server, not even the runtime ones. So by that logic even react might be seen as a development dependency.

我们曾经尝试将它们分开,但是如上所述,它并不是一开始就很一致。没有技术上的原因为什么这种区别对没有Node运行时的应用有用。此外,它还会给某些Heroku部署造成问题,这些部署没有安装开发依赖项(因此无法在服务器上构建项目或无法在部署之前进行测试)。

We used to try to separate them but as explained above, it isn't really consistent in the first place. There's no technical reason why this distinction is useful for apps that have no Node runtime. In addition, it used to cause problems for some Heroku deployments that didn't install development dependencies (and thus weren't able to build the project on the server or test it right before deployment).

最后,我们只是将所有内容放入依赖项中。如果您不同意,则可以随时按照您认为合理的方式重新排列 package.json

In the end we went with just putting everything into dependencies. If you disagree you can always rearrange package.json as you deem reasonable.

这篇关于依赖项部分中的create-react-app install devDepencies的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆