当我使用
运行我的角度2项目时npm start
我有这样的错误。我在我的项目中使用webpack。这是我的Webpack
const path = require('path');
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
module.exports = {
entry: {
server: './src/server.ts'
},
resolve: {
extensions: ['.ts', '.js']
},
target: 'node',
plugins: [
new webpack.NormalModuleReplacementPlugin(/\.\.\/environments\/environment/, '../environments/environment.prod')
],
externals: [nodeExternals({
whitelist: [
/^ng2-timeout/
]
})],
node: {
__dirname: true
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js'
},
module: {
rules: [
{ test: /\.ts$/, loader: 'ts-loader' }
]
}
}
答案 0 :(得分:0)
通过从webpack文件中删除此代码来解决此问题
plugins: [
new webpack.NormalModuleReplacementPlugin(/\.\.\/environments\/environment/, '../environments/environment.prod')
],