Node.js 如何独立运行node js dist?

Node.js 如何独立运行node js dist?,node.js,webpack,node-modules,Node.js,Webpack,Node Modules,我用strapi和nuxt制作了nodejs web应用程序。它对pm2有效 module.exports = { apps: [ { exec_mode: 'cluster', name: 'back', instances: '2', script: './node_modules/strapi/bin/strapi.js', args: 'start', }, { name: 'front'

我用strapi和nuxt制作了nodejs web应用程序。它对pm2有效

module.exports = {
  apps: [
    {
      exec_mode: 'cluster',
      name: 'back',
      instances: '2',
      script: './node_modules/strapi/bin/strapi.js',
      args: 'start',
    },
    {
      name: 'front',
      exec_mode: 'cluster',
      instances: '2', 
      script: './node_modules/nuxt/bin/nuxt.js',
      args: 'start'
    }
  ],
};
如何在没有node_modules文件夹和源的情况下启动bundle

这两个框架都生成服务器js和客户端页面

一样,但过时了。我试图配置加载程序,但没有成功

./servers/api.js

const strapi = require('strapi');
strapi().start();
./webpack.config.js

var webpack = require('webpack');
var path = require('path');
var fs = require('fs');


const config = {
  mode: 'development',
  mode: 'production', */
  target: 'node',
  /*externals: nodeModules,*/
  entry: {
    strapi: './servers/api.js',
    /* nuxt: require.resolve('nuxt/bin/nuxt.js'),*/
  },
  output: {
    path: __dirname, /* path.join(__dirname, 'backend'), */
    filename: '[name].bundle.js',
    libraryTarget: 'commonjs2',
  },

  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': '"production"',
      }
    })
  ],

  module: {
    rules: [
      {
        test: /\.js$/,
        use: [
          {
            loader: 'babel-loader',
            options: {
              presets: [
                [
                  'env',
                  {
                    targets: {
                      node: 'current',
                    },
                  },
                ],
              ],
            },
          },
        ],
      },
    ],
  },
};

module.exports = config;
启动时出错

$ node strapi.bundle.js 
undefined:14
"production" = "production" || false;
^^^^^^^^^^^^

SyntaxError: Invalid left-hand side in assignment
    at Object../node_modules/strapi/lib/core/app-configuration/index.js (/mnt/data/Projects/2021/cms/nuxt/kiosk/strapi.bundle.js:11756:1)
    at __webpack_require__ (/mnt/data/Projects/2021/cms/nuxt/kiosk/strapi.bundle.js:21:30)
    at eval (webpack:///./node_modules/strapi/lib/Strapi.js?:30:27)
    at Object../node_modules/strapi/lib/Strapi.js (/mnt/data/Projects/2021/cms/nuxt/kiosk/strapi.bundle.js:11629:1)
    at __webpack_require__ (/mnt/data/Projects/2021/cms/nuxt/kiosk/strapi.bundle.js:21:30)
    at eval (webpack:///./node_modules/strapi/lib/index.js?:3:18)
    at Object../node_modules/strapi/lib/index.js (/mnt/data/Projects/2021/cms/nuxt/kiosk/strapi.bundle.js:11936:1)
    at __webpack_require__ (/mnt/data/Projects/2021/cms/nuxt/kiosk/strapi.bundle.js:21:30)
    at eval (webpack:///./servers/api.js?:3:16)
    at Object../servers/api.js (/mnt/data/Projects/2021/cms/nuxt/kiosk/strapi.bundle.js:13313:1)

如何在没有节点_模块的情况下运行?它包含所有依赖文件。所有依赖文件捆绑在
server.js
中,您会遇到什么错误?@iAviator更新了“NODE_ENV”:
“production”
,应该是“NODE_ENV”:
“production”,
。为什么在上面的json中定义了2次mode属性?