将源复制到新目录时,npm run build会引发错误代码ELIFECYCLE

时间:2019-05-24 08:39:39

标签: typescript npm webpack

我正在尝试使用npm构建一个项目(我不确定是NodeJS还是ReactJS还是其他任何东西。我只想部署它)。

我运行2条以下命令:

npm install
npm run build

当我在从github克隆的项目文件夹中运行这些命令时,一切正常。 但是当我复制所有内容时(原始源代码。我不会复制到新文件夹,然后在该新文件夹中运行命令,“ npm run build”会引发错误

npm ERR! code ELIFECYCLE 
npm ERR! errno 1    
npm ERR! eventify-ui@0.0.1 build: `webpack --config webpack.config.js`    
npm ERR! Exit status 1    
npm ERR!     
npm ERR! Failed at the eventify-ui@0.0.1 build script.    
npm ERR! This is probably not a problem with npm. There is likely dditional logging output above.

这是我的webpack.config.js:

module.exports =    
  process.env.NODE_ENV === 'production'    
    ? require('./config/webpack.prod')    
    : require('./config/webpack.dev');

我的./config/webpack.prod.js:

const path = require('path');    
const webpack = require('webpack');    
const HtmlWebpackPlugin = require('html-webpack-plugin');    
const merge = require('webpack-merge');    
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');    
const TerserPlugin = require('terser-webpack-plugin');    
const baseConfig = require('./webpack.base');    
module.exports = merge(baseConfig, {    
  optimization: {    
    minimizer: [    
      new TerserPlugin({}),    
      new OptimizeCSSAssetsPlugin({})    
    ],    
  },    
  mode: 'production',    
  plugins: [    
    new webpack.HashedModuleIdsPlugin(),    
        new HtmlWebpackPlugin({
          template: path.resolve('./src/web/index.html'),
        }),
        new webpack.LoaderOptionsPlugin({
          minimize: true,
          debug: false,
        }),
      ],
    });

我的./config/webpack.dev.js:

const merge = require('webpack-merge');    
const baseConfig = require('./webpack.base');    
module.exports = merge(baseConfig, {    
  mode: 'development',    
  devtool: 'source-map',    
  devServer: {    
        port: 4200,
    historyApiFallback: true,    
    contentBase: './',    
    proxy: {    
      '/api': {    
        target: 'http://192.168.74.62:8080',    
        secure: false,    
      },    
    },    
  },    
});

编辑:我注意到当我在原始文件夹中运行npm run build时,控制台日志如下:

> eventify-ui@0.0.1 build /home/hientle/Desktop/UI/eventify-ui
> webpack --config webpack.config.js

ℹ 「atl」: Using typescript@3.4.5 from typescript
ℹ 「atl」: Using tsconfig.json from /home/hientle/Desktop/UI/eventify-ui/tsconfig.json
ℹ 「atl」: Checking started in a separate process...
ℹ 「atl」: Time: 5998ms

当我在新文件夹中构建时,它不会显示那些打字稿行

> eventify-ui@0.0.1 build /home/hientle/Desktop/UI/manual
> webpack --config webpack.config.js

/home/hientle/Desktop/UI/manual/node_modules/webpack-cli/bin/cli.js:74
                throw err;
                ^

编辑2:为了清楚起见,我复制文件夹的内容,而不是文件夹本身。这在我的计算机(1个Ubuntu和1个CentOS)上发生。当我在编写代码的人(他使用Windows)的计算机上尝试此操作时,没有出现此错误。

0 个答案:

没有答案
相关问题