小编Str*_*ch0的帖子

Webpack构建错误

与webpack有一些问题.它建立得很好但是当我打开我的网站时,我得到:Getting error: "Uncaught ReferenceError: webpackJsonp is not defined"

我相信我的CommonsChunkPlugin在我的应用程序捆绑之前正在运行?

知道我的配置src/config/webpack.config.js正在建设中可能会有所帮助dist/js/.

已阅读https://medium.com/@MarkEwersDev/note-to-self-if-you-ever-get-this-uncaught-referenceerror-webpackjsonp-is-not-defined-message-and-d354f5c4d335#.9cysuil5phttps://github.com/webpack/webpack/issues/368但似乎没有帮助,除非我遗漏了什么.

  devtool: 'source-map',
  entry: {
    vendor: [
      'react', 'react-dom', 'react-router', 'react-helmet', 'react-redux', 'moment-timezone', 'cookies-js', 'superagent', 'classnames', 'es6-promise'
    ],
    app: [
      './src/client/entry',
      './scss/main.scss',

    ]
  }
  output:{
    path: __dirname + '../../dist/js',
    filename: 'app.js'
  }
  plugins:[
    new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js'),

    new ExtractTextPlugin('../css/app.css', {
        allChunks: true
    }),
    new webpack.DefinePlugin({
      'process.env':{
        'NODE_ENV': JSON.stringify('production')
      }
    }),
    new webpack.optimize.AggressiveMergingPlugin(),
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: true
      },
      output: …
Run Code Online (Sandbox Code Playgroud)

javascript node.js webpack

4
推荐指数
1
解决办法
5680
查看次数

在Facebook机器人聊天中存储用户答案的​​最佳方式?

使用Claudia JS构建Facebook messenger机器人并计划在AWS Lambda上托管.

我想问一下用户一系列问题.

当用户回答答案时,我需要保存以供日后使用,一旦我掌握了所需的所有信息,我会将答案传递给函数.

保存此信息的最佳方法是什么?

我正在考虑一些缓存层,例如redis,但因为存储在RAM中,当lamda服务器关闭时我会丢失它.Mongodb在连接时显然有很多开销,但至少会持久.

也许只是一个简单的mySQL服务器?

别人怎么做?我觉得有一个我想念的简单解决方案.

database chatbot node.js aws-lambda facebook-chatbot

4
推荐指数
1
解决办法
2239
查看次数

如何防止联系表格7发送电子邮件

我使用联系表格7来生成表格和处理表格提交.

我也使用Hubspot集成来捕获表单提交数据,因此,不需要从Contact Form 7发送任何电子邮件.

有没有办法禁用试图发送的电子邮件?

php wordpress contact-form-7 hubspot

4
推荐指数
1
解决办法
7500
查看次数

如何对 react-bootstrap Table 组件进行排序

我是 React 的新手,正在使用react-bootstrap 中的 Table 组件。

我想按“到期前的天数”列的升序对表格进行排序。 我的反应应用

但是 Table 组件没有排序属性,有人知道我该怎么做吗?

html-table reactjs react-bootstrap react-bootstrap-table

4
推荐指数
1
解决办法
1万
查看次数

当 devDependency 未安装时,如何在生产环境中运行构建和测试?

我确信这是一个常见问题,但我似乎找不到明确的答案。

我有一个节点应用程序,为了构建它需要一些 devDependency,例如babel. 为了运行我的测试还需要 devDependency,例如jest. 但是当 CI 在生产环境中运行时,它显然没有安装任何 devDependency,因此我会收到找不到包的错误。

在没有 devDependency 的情况下在 prod 中运行构建和测试的最佳实践是什么?

如果有帮助,我正在 GitLab Pipelines 中运行我的构建:

image: node:8.11.2

stages:
  - prepare
  - test
  - deploy

install_and_build:
  stage: prepare
  script:
    - npm install yarn
    - yarn
    - yarn build
  only:
    - master

test:
  stage: test
  script:
    - yarn test
  only:
    - master

deploy_production:
  type: deploy
  stage: deploy
  image: ruby:latest
  script:
    - apt-get update -qy
    - apt-get install -y ruby-dev
    - gem install dpl
    - dpl …
Run Code Online (Sandbox Code Playgroud)

deployment continuous-integration node.js npm babeljs

4
推荐指数
1
解决办法
1171
查看次数

如何在打字稿中使用 promise.allSettled?

打字稿构建失败,因为它似乎不喜欢Promise.allSetttled即使我已经设置了 ts config comilerOptions"lib": [ "ES2020.Promise" ],

似乎对 的响应promise.allSettled不包括resultreason

运行 typescript build 时出现以下错误:

Property 'reason' does not exist on type 'PromiseSettledResult<IMyPromiseResult>'.
Run Code Online (Sandbox Code Playgroud)

Property 'value' does not exist on type 'PromiseRejectedResult'.
Run Code Online (Sandbox Code Playgroud)

我的代码块看起来像这样,正如您所看到的,我正在尝试访问reasonresult从中获取已解决的承诺。

const myPromise = async () : Promise<IMyPromiseResult> {
  return new Promise((resolve) => {
    resolve("hello world")
  })
}

const data = await Promise.allSettled([
  myPromise()
]);

const response = data.find(res => res.status === 'fulfilled')?.result;

if(!response) {
  const error …
Run Code Online (Sandbox Code Playgroud)

javascript node.js promise typescript

4
推荐指数
3
解决办法
4514
查看次数

如何在 GraphQL 中设置 http 状态码

I want to set an http status code in my GraphQL authentication query, depending on if auth attempt was successful (200), unauthorised (401) or missing parameters (422).

I am using Koa and Apollo and have configured my server like so:

const graphqlKoaMiddleware = graphqlKoa(ctx => {
  return ({
    schema,
    formatError: (err) => ({ message: err.message, status: err.status }),
    context: {
      stationConnector: new StationConnector(),
      passengerTypeConnector: new PassengerTypeConnector(),
      authConnector: new AuthConnector(),
      cookies: ctx.cookies
    }
  })
})

router.post("/graphql", graphqlKoaMiddleware)
Run Code Online (Sandbox Code Playgroud)

As you can see, …

http-status-codes koa graphql apollo-server

3
推荐指数
1
解决办法
5327
查看次数

如何避免附加多个事件监听器?

以下代码是否要附加多个事件侦听器,或者 React Native / expo-linking 是否只允许一次附加一个事件侦听器?

import * as Linking from 'expo-linking'
import { useIsFocused } from '@react-navigation/native'

const MyComponent = () => {
  const isFocused = useIsFocused()

  useEffect(() => {
    fetchData()
    Linking.addEventListener('url', _handleEvent)
  }, [isFocused])

  const fetchData = () => {
    // ...
  }

  const _handleEvent = () => {
    // ...
  }

  return (
    <View><View>
  )
}
Run Code Online (Sandbox Code Playgroud)

有没有办法检查事件侦听器是否已存在,以便我可以执行以下操作:

useEffect(() => {
  fetchData()
  if(!eventListenerExists){
    Linking.addEventListener('url', _handleEvent)
  }
}, [isFocused])
Run Code Online (Sandbox Code Playgroud)

javascript react-native react-navigation expo

3
推荐指数
1
解决办法
1795
查看次数

无法用红宝石宝石安装sass.无法构建gem原生扩展

尝试在位桶管道中安装sass docker实例并获取错误 Failed to build gem native extension

日志显示以下内容:

gem install sass --no-user-install
Successfully installed rb-fsevent-0.10.2
Building native extensions.  This could take a while...
ERROR:  Error installing sass:
    ERROR: Failed to build gem native extension.
Run Code Online (Sandbox Code Playgroud)

我正在使用图像 php:7.1.1

应该像我运行的脚本一样安装Ruby和Gem:

apt-get update && apt-get install -y unzip nodejs ruby-full
gem install sass --no-user-install
Run Code Online (Sandbox Code Playgroud)

提前致谢

ruby rubygems sass docker bitbucket-pipelines

2
推荐指数
1
解决办法
699
查看次数

如何向 GraphQL Codegen 添加自定义标量?

我的 GraphQL 模式中有一个自定义标量,我希望我的 Codegen 为我生成正确的类型。

我的架构如下所示:

scalar Decimal

type Item {
  price: Decimal!
}
Run Code Online (Sandbox Code Playgroud)

我为此标量添加了一个使用 [Decimal.js][1] 的自定义解析器。

当我从此架构生成 Typescript 类型时,我希望它能够识别price为 Decimal 类型并具有 Decimal.js 提供的属性。

我的代码生成配置如下所示:

schema: "./src/typeDefs/index.ts"
generates:
  ./src/types.d.ts:
    config:
      scalars:
        Decimal: Decimal
    plugins:
      - typescript
      - typescript-resolvers
Run Code Online (Sandbox Code Playgroud)

虽然这会生成Decimal类型,但它不会将其识别为 Decimal.js 的类型,因此它没有库公开的任何方法。

它生成以下类型:

export type Scalars = {
  ID: string;
  String: string;
  Boolean: boolean;
  Int: number;
  Float: number;
  Decimal: Decimal; // doesn't have any Decimal.js props
};
Run Code Online (Sandbox Code Playgroud)

如何告诉 codegen 使用 Decimal.js 生成正确的 Decimal 类型?[1]: https: //www.npmjs.com/package/decimal.js

javascript node.js graphql prisma graphql-codegen

2
推荐指数
1
解决办法
3692
查看次数