node.js - 当我没有 webpack.config.js 文件时在哪里添加disableHostCheck

标签 node.js reactjs webpack

首先,如果这是一个荒谬的基本问题,我很抱歉,但这里是:

我已经构建了一个 create-react-app,因此虽然 webpack 和 webpack-dev-server 位于我的 node-modules 文件夹中,但似乎没有 webpack.config.js 文件供我包含 disableHostCheck 语句,因此我收到“无效主机头”消息。或者如果使用了 create-react-app ,我是否应该不必更改任何内容。以防万一它可以帮助我的 package.json 看起来像这样:

{
  "name": "recipe",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "^0.18.0",
    "express": "^4.16.3",
    "fetch": "^1.1.0",
    "prop-types": "^15.6.0",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-scripts": "1.1.0"
  },
  "proxy": "http://localhost:8081",
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

如您所见,我已将 API 代理到 8081,并且正在 8080 上运行 React。谢谢。

最佳答案

您应该首先运行“npm runject”以使所有反应脚本、配置等可见。之后,您应该能够在“config”文件夹中看到您的 webpack.config 文件。

关于node.js - 当我没有 webpack.config.js 文件时在哪里添加disableHostCheck,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49556072/

相关文章:

javascript - 即使条件不满足,if 条件也会被执行

javascript - 如何捆绑 npm 包以便在脚本中从中导入对象?

javascript - 将鼠标悬停在文本上时创建叠加层

node.js - Docker CentOS 镜像 NodeJS

node.js - Node/表达 : How to POST to an external form with data?

reactjs - react 钩子(Hook) : Is there a way to calculate state values based on another state value

javascript - 从 URL 获取图像并在 React JS 中设置为背景

javascript - 如果webpack摇树处理node_modules?

javascript - 使用 webpack 加载器时“找不到模块”

node.js - 使用 lerna 类型-graphql --- 错误 : Cannot determine GraphQL output type for id