问答

webpack 打包 typescript nestjs项目, 打包之后的 main.js 无法

作者:admin 2021-05-14 我要评论

我是个nodejs小菜鸡,在用nestjs写一个微服务架构的接口应用。我想通过webpack将这个项目打包为一个main.js文件。在github上找了一个 脚手架 按照人家的方式配置...

在说正事之前,我要推荐一个福利:你还在原价购买阿里云、腾讯云、华为云服务器吗?那太亏啦!来这里,新购、升级、续费都打折,能够为您省60%的钱呢!2核4G企业级云服务器低至69元/年,点击进去看看吧>>>)

我是个nodejs小菜鸡,在用nestjs写一个微服务架构的接口应用。我想通过webpack将这个项目打包为一个main.js文件。在github上找了一个脚手架 按照人家的方式配置,但是一样的配置放到我的项目里打包之后执行 node main.js 会抛出一个错误

throw new errors_1.CannotDetermineTypeError((_a = target.constructor) === null || _a === void 0 ? void 0 : _a.name, propertyKey);
        ^
CannotDetermineTypeError: Cannot determine a type for the "n.operation" field (union/intersection/ambiguous type was used). Make sure your property is decorated with a "@Prop({ type: TYPE_HERE })"

我的webpack配置是这样的:

const path = require('path');
const webpack = require('webpack');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const { NODE_ENV = 'production' } = process.env;
console.log(`-- Webpack <${NODE_ENV}> build --`);
module.exports = {
  entry: './src/main.ts',
 mode: NODE_ENV,
 target: 'node',
 output: {
    path: path.resolve(__dirname, 'dist'),
 filename: 'main.js'
 },
 resolve: {
    extensions: ['.ts', '.js'],
 plugins: [new TsconfigPathsPlugin({ configFile: './tsconfig.build.json' })]
  },
 module: {
    rules: [
      {
        test: /.ts$/,
 use: ['ts-loader']
      }
    ]
  },
 stats: {
    warningsFilter: [
      'node_modules/express/lib/view.js',
     'node_modules/@nestjs/common/utils/load-package.util.js',
     'node_modules/@nestjs/core/helpers/load-adapter.js',
     'node_modules/mongoose/lib/index.js',
     'node_modules/mqtt/node_modules/ws/lib/buffer-util.js',
     'node_modules/mqtt/node_modules/ws/lib/validation.js',
     'node_modules/mongodb/lib/operations/connect.js',
     'node_modules/grpc/src/grpc_extension.js',
     'node_modules/bytebuffer/dist/bytebuffer-node.js',
     'node_modules/@nestjs/core/helpers/optional-require.js',
     'node_modules/require_optional/index.js',
     'node_modules/node-pre-gyp/lib/util/versioning.js',
     'node_modules/node-pre-gyp/lib/pre-binding.js',
     'node_modules/ws/lib/buffer-util.js',
     'node_modules/ws/lib/validation.js',
     warning => false
     ]
      }
    };

请各位大佬帮小弟看看,这到底是个啥问题。

版权声明:本文转载自网络,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。本站转载出于传播更多优秀技术知识之目的,如有侵权请联系QQ/微信:153890879删除

相关文章
  • 请问下prometheus怎么进行自定义的按业

    请问下prometheus怎么进行自定义的按业

  • 节流函数为什么,点击无效,监听窗口大

    节流函数为什么,点击无效,监听窗口大

  • express访问静态资源失败

    express访问静态资源失败

  • IE 浏览器下 match 方法报错

    IE 浏览器下 match 方法报错

腾讯云代理商
海外云服务器