【发布时间】:2016-09-15 23:02:42
【问题描述】:
我需要帮助。我正在尝试使用 node.js 来处理在我的网站上发送电子邮件。我希望我的电子邮件表单继续并在提交时发送电子邮件,而不是使用基本的“mailto”操作。我将 Sendgrid 作为我的电子邮件服务来处理 API 和其他服务器端任务。
我不断收到此错误,我认为这是 Webpack 问题。 enter image description here 我还将发布几行代码。
你对我能做什么有什么想法吗?
//Webpack.config 文件
"use strict";
var webpack = require('webpack');
var loaders = require('./webpack.loaders');
var HtmlWebpackPlugin = require('html-webpack-plugin');
const HOST = process.env.HOST || "127.0.0.1";
const PORT = process.env.PORT || "8888";
// global css
loaders.push({
test: /[\/\\](node_modules|global)[\/\\].*\.css$/,
loaders: [
'css-loader!autoprefixer-loader?browsers=last 2 versions',
'style-loader!css-loader!autoprefixer-loader',
'style?sourceMap',
'css'
]
});
//local sass modules
loaders.push({
test: /[\/\\]src[\/\\].*\.sass/,
loaders: [
'style?sourceMap',
'css-loader!autoprefixer-loader?browsers=last 2 versions',
'style-loader!css-loader!autoprefixer-loader',
'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]',
'sass'
]
});
//local css modules
loaders.push({
test: /[\/\\]src[\/\\].*\.css/,
loaders: [
'style?sourceMap',
'css-loader!autoprefixer-loader?browsers=last 2 versions',
'style-loader!css-loader!autoprefixer-loader',
'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]'
]
});
module.exports = {
entry: [
`webpack-dev-server/client?http://${HOST}:${PORT}`,
`webpack/hot/only-dev-server`,
`./src/index.jsx` // Your appʼs entry point
],
devtool: process.env.WEBPACK_DEVTOOL || 'cheap-module-source-map',
output: {
path:__dirname,
filename: './src/bundle.js'
},
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
loaders
},
devServer: {
// do not print bundle build stats
noInfo: true,
// enable HMR
hot: true,
// embed the webpack-dev-server runtime into the bundle
inline: true,
// serve index.html in place of 404 responses to allow HTML5 history
historyApiFallback: true,
port: PORT,
host: HOST
},
plugins: [
new webpack.NoErrorsPlugin(),
new webpack.HotModuleReplacementPlugin(),
]
};
【问题讨论】:
-
在项目目录的控制台中你可以试试
npm install --save-dev bluebird再试一次吗? -
我这样做了,但仍然出现第二个错误。该模块无法解析。
-
看起来它是一个未解决的问题github.com/sendgrid/sendgrid-nodejs/issues/289
-
好吧,我想我得另找办法了。我等不及要解决这个问题了。不过,感谢您的帮助。
标签: javascript node.js reactjs webpack sendgrid