2016-09-15 25 views
0

我需要帮助。我正在尝试使用node.js来处理在我的网站上发送电子邮件。我希望我的电子邮件表格能够继续发送并提交提交的电子邮件,而不是使用基本的“mailto”操作。我将Sendgrid作为我的电子邮件服务来处理API和其他服务器端任务。Sendgrid Node.js库不能与React配合使用

我不断收到此错误,我认为这是一个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(), 
    ] 
}; 
+0

在控制台的项目目录下你能不能试试'npm install --save-dev bluebird'并重试? – finalfreq

+0

我这样做,我仍然得到第二个错误。该模块无法解析。 –

+0

看起来像一个公开问题https://github.com/sendgrid/sendgrid-nodejs/issues/289 – finalfreq

回答

0

我居然找到了解决这一

这不是在这个月底回购的问题,你的WebPack配置只需要一个JSON装载机,看到这问题:

https://github.com/webpack/webpack/issues/303

我解决我自己添加{ test: /\.json$/, loader: 'json'}我webpackloaders

你也可能需要做npm install json-loader --module-bind json

相关问题