找不到输入模块中的错误:错误:无法解析“ ./src”

时间:2020-04-26 06:10:21

标签: node.js heroku webpack

将我的webpack nodejs项目部署到Heroku时,出现以下错误:

remote:        ERROR in Entry module not found: Error: Can't resolve './src' in '/tmp/build_d02ddb6dc3a6731770d4ea56287bd83b'
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 2
remote: npm ERR! myapp@1.0.6 heroku-postbuild: `webpack -p`
remote: npm ERR! Exit status 2
remote: npm ERR! 
remote: npm ERR! Failed at the myapp@1.0.6 heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote: 
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /tmp/npmcache.c2UnE/_logs/2020-04-26T05_55_17_906Z-debug.log
remote: 
remote: -----> Build failed
remote:        
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:        
remote:        Some possible problems:
remote:        
remote:        - Node version not specified in package.json
remote:          https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
remote:        
remote:        Love,
remote:        Heroku
remote:        
remote:  !     Push rejected, failed to compile Node.js app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: 

我的webpack配置如下:

const path = require('path')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')

// exclude: /node_modules\/(?!(material-kit-react)\/).*/,

module.exports = {
    entry: {
        app: [
            './client/index',
            'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=2000&overlay=false&reload=true'
        ]
    },
    output: {
        filename: '[name].bundle.js',
        path: path.resolve(__dirname, 'dist'),
        publicPath: '/'
    },
    resolve: {
        extensions: ['.js', '.jsx', '.json', '.scss'],
        modules: [
            'node_modules'
        ]
    },
    module: {
        rules: [
        {
            test: /\.(png|jpe?g|gif)$/i,
            use: [
              {
                loader: 'file-loader',
              },
            ],
        },
        {
            test: /\.m?js(x)?$/,
            exclude: /node_modules/,
            use: {
                loader: 'babel-loader',
                options: {
                    presets: [
                         "@babel/preset-env"
                    ]
                }
            }
        },{ test: /\.css$/, use: ['style-loader', 'css-loader'] },{
            test: /\.scss$/,
            use: [{
                loader: 'style-loader'
            }, {
                loader: 'css-loader',
                options: {
                    sourceMap: true
                }
            }, {
                loader: 'sass-loader',
                options: {
                    sourceMap: true
                }
            }]
        }
        ]
    },
    plugins: [
        new CleanWebpackPlugin(),
        new HtmlWebpackPlugin({
            title: 'Myapp',
            template: path.resolve(__dirname, 'client', 'index.html'),
            filename: 'index.html'
        })
    ]
}

我不确定为什么我的应用程序会考虑查找“ ./src”路径或将在何处设置该路径,因为我没有在任何地方进行配置。如何在heroku上正确编译我的nodejs应用程序?

0 个答案:

没有答案