Javascript 网页包:TypeError:无法读取属性';属性';未定义的

Javascript 网页包:TypeError:无法读取属性';属性';未定义的,javascript,webpack,Javascript,Webpack,以下是有关分行和回购协议: /Users/leongaban/projects/Futuratum/moon.holdings/node_modules/webpack cli/bin/config yargs.js:89 描述:选项Schema.definitions.output.properties.path.description 我不知道为什么会出现这个错误,但我从网页3升级到了网页4 网页包 /* eslint-disable no-console */ import webpack

以下是有关分行和回购协议:

/Users/leongaban/projects/Futuratum/moon.holdings/node_modules/webpack cli/bin/config yargs.js:89 描述:选项Schema.definitions.output.properties.path.description

我不知道为什么会出现这个错误,但我从网页3升级到了网页4

网页包

/* eslint-disable no-console */
import webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import path from 'path';

const moonholdings = path.resolve(__dirname, 'moonholdings');
const app = path.resolve(__dirname, 'app');
const nodeModules = path.resolve(__dirname, 'node_modules');

const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
  template: path.join(__dirname, '/app/index.html'),
  inject: 'body'
});

const ExtractTextPluginConfig = new ExtractTextPlugin({
  filename: 'moonholdings.css',
  disable: false,
  allChunks: true
});

const CopyWebpackPluginConfigOptions = [{
  from: 'app/static',
  to: 'static/'
}];

const CopyWebpackPluginConfig = new CopyWebpackPlugin(CopyWebpackPluginConfigOptions);

const PATHS = {
  app,
  build: moonholdings
};

const LAUNCH_COMMAND = process.env.npm_lifecycle_event;

const isProduction = LAUNCH_COMMAND === 'production';
process.env.BABEL_ENV = LAUNCH_COMMAND;

const productionPlugin = new webpack.DefinePlugin({
  'process.env': {
    NODE_ENV: JSON.stringify('production')
  }
});

const base = {
  entry: ['babel-polyfill', PATHS.app],
  performance: {
    hints: false,
    maxAssetSize: 1000000
  },
  output: {
    path: PATHS.build,
    publicPath: '/',
    filename: 'index_bundle.js'
  },
  resolve: {
    modules: [app, nodeModules]
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/
      },
      {
        test: /\.s?css/,
        use: [
          'style-loader',
          'css-loader',
          'sass-loader'
        ]
      },
      {
        test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)/,
        loader: 'file-loader?name=[path][name].[ext]'
      }
    ]
  }
};

const developmentConfig = {
  devtool: 'inline-source-map',
  devServer: {
    contentBase: moonholdings
  },
  plugins: [
    CopyWebpackPluginConfig,
    ExtractTextPluginConfig,
    HtmlWebpackPluginConfig
  ]
};

const productionConfig = {
  devtool: false,
  plugins: [
    CopyWebpackPluginConfig,
    ExtractTextPluginConfig,
    HtmlWebpackPluginConfig,
    productionPlugin
  ]
};

export default Object.assign(
  {}, base,
  isProduction === true ? productionConfig : developmentConfig
);
package.json

{
  "name": "moon.holdings",
  "version": "1.0.0",
  "description": "Cryptocurrency asset portfolio",
  "main": "index.js",
  "repository": "https://github.com/Futuratum/moon.holdings.git",
  "author": "Leon Gaban <leongaban@gmail.com>",
  "license": "MIT",
  "scripts": {
    "start": "webpack && webpack-dev-server",
    "webpack": "webpack-dev-server",
    "dev": "webpack-dev-server",
    "build": "webpack -p",
    "production": "webpack -p",
    "test": "yarn run test-eslint; yarn run test-jest:update",
    "test-eslint": "eslint app",
    "test-eslint:fix": "eslint --fix app",
    "test-sasslint": "./node_modules/.bin/sass-lint 'app/**/*.scss' -v -q",
    "test-jest": "jest",
    "test-jest:watch": "jest --watch",
    "test-jest:coverage": "jest --coverage",
    "test-jest:update": "jest --updateSnapshot"
  },
  "setupFiles": [
    "<rootDir>/config/polyfills.js",
    "<rootDir>/src/setupTests.js"
  ],
  "now": {
    "name": "moonholdings",
    "alias": "moon.holdings"
  },
  "jest": {
    "moduleNameMapper": {},
    "moduleFileExtensions": [
      "js",
      "jsx"
    ],
    "moduleDirectories": [
      "node_modules",
      "app"
    ],
    "setupTestFrameworkScriptFile": "./app/utils/testConfigure.js"
  },
  "dependencies": {
    "axios": "^0.18.0",
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.0",
    "babel-eslint": "^8.2.2",
    "babel-loader": "^7.1.4",
    "babel-plugin-transform-async-to-generator": "^6.24.1",
    "babel-plugin-transform-es2015-destructuring": "^6.23.0",
    "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.6.1",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "babel-preset-react-hmre": "^1.1.1",
    "babel-preset-stage-0": "^6.24.1",
    "babel-register": "^6.26.0",
    "copy-webpack-plugin": "^4.5.0",
    "css-loader": "^0.28.10",
    "enzyme": "^3.3.0",
    "enzyme-adapter-react-16": "^1.1.1",
    "enzyme-to-json": "^3.3.1",
    "eslint": "^4.18.2",
    "eslint-config-airbnb": "^16.1.0",
    "eslint-import-resolver-node": "^0.3.2",
    "eslint-plugin-dependencies": "^2.4.0",
    "eslint-plugin-import": "^2.9.0",
    "eslint-plugin-jsx-a11y": "^6.0.3",
    "eslint-plugin-react": "^7.7.0",
    "extract-text-webpack-plugin": "^3.0.2",
    "file-loader": "^1.1.11",
    "flexboxgrid": "^6.3.1",
    "git-hooks": "^1.1.10",
    "history": "^4.7.2",
    "html-webpack-plugin": "^3.0.6",
    "jest": "^22.4.2",
    "lodash": "^4.17.10",
    "node-sass": "^4.7.2",
    "path-to-regexp": "^2.2.0",
    "ramda": "^0.25.0",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-hot-loader": "^4.0.0",
    "react-redux": "^5.0.7",
    "react-router": "^4.2.0",
    "react-router-dom": "^4.2.2",
    "react-router-redux": "^4.0.8",
    "react-sortable-hoc": "^0.6.8",
    "react-test-renderer": "^16.3.2",
    "redux": "^3.7.2",
    "redux-mock-store": "^1.5.1",
    "redux-thunk": "^2.2.0",
    "rest": "^2.0.0",
    "sass-lint": "^1.12.1",
    "sass-loader": "^6.0.7",
    "style-loader": "^0.20.2",
    "svg-inline-loader": "^0.8.0",
    "svg-loader": "^0.0.2",
    "url-loader": "^1.0.1",
    "webpack": "^4.20.2",
    "webpack-cli": "^2.0.10",
    "webpack-dev-server": "2.11.1"
  }
}
{
“名称”:“月亮控股”,
“版本”:“1.0.0”,
“说明”:“加密货币资产组合”,
“main”:“index.js”,
“存储库”:https://github.com/Futuratum/moon.holdings.git",
“作者”:“Leon Gaban”,
“许可证”:“麻省理工学院”,
“脚本”:{
“开始”:“网页包和网页包开发服务器”,
“网页包”:“网页包开发服务器”,
“开发”:“网页包开发服务器”,
“构建”:“网页包-p”,
“制作”:“网页包-p”,
“测试”:“纱线运行测试eslint;纱线运行测试笑话:更新”,
“测试eslint”:“eslint应用程序”,
“test-eslint:fix”:“eslint--fix-app”,
“测试sasslint”:“/node_modules/.bin/sass lint”app/***.scss'-v-q”,
“测试笑话”:“笑话”,
“测试笑话:看”:“笑话——看”,
“测试笑话:覆盖范围”:“笑话——覆盖范围”,
“测试jest:更新”:“jest--updateSnapshot”
},
“设置文件”:[
“/config/polyfills.js”,
“/src/setupTests.js”
],
“现在”:{
“名称”:“月亮控股”,
“别名”:“moon.holdings”
},
“笑话”:{
“moduleNameMapper”:{},
“moduleFileExtensions”:[
“js”,
“jsx”
],
“模块目录”:[
“节点_模块”,
“应用程序”
],
“SetupTestFrameworkScript文件”:“/app/utils/testConfigure.js”
},
“依赖项”:{
“axios”:“^0.18.0”,
“巴别塔cli”:“^6.26.0”,
“巴别塔核心”:“^6.26.0”,
“babel eslint”:“^8.2.2”,
“巴别塔加载器”:“^7.1.4”,
“babel插件异步转换为生成器”:“^6.24.1”,
“babel-plugin-transform-es2015-destructuring”:“^6.23.0”,
“babel-plugin-transform-es2015-modules-commonjs”:“^6.26.0”,
“巴别塔插件转换对象静止排列”:“^6.26.0”,
“巴别塔插件转换运行时”:“^6.23.0”,
“巴别塔polyfill”:“^6.26.0”,
“巴别塔预设环境”:“^1.6.1”,
“babel-preset-es2015”:“^6.24.1”,
“巴别塔预设反应”:“^6.24.1”,
“巴别塔预设反应hmre”:“^1.1.1”,
“babel-preset-stage-0”:“^6.24.1”,
“巴别塔寄存器”:“^6.26.0”,
“复制网页包插件”:“^4.5.0”,
“css加载器”:“^0.28.10”,
“酶”:“^3.3.0”,
“酶-适配器-反应-16”:“^1.1.1”,
“酶到json”:“^3.3.1”,
“eslint”:“^4.18.2”,
“eslint配置airbnb”:“^16.1.0”,
“eslint导入冲突解决程序节点”:“^0.3.2”,
“eslint插件依赖项”:“^2.4.0”,
“eslint插件导入”:“^2.9.0”,
“eslint-plugin-jsx-a11y”:“^6.0.3”,
“eslint插件反应”:“^7.7.0”,
“提取文本网页包插件”:“^3.0.2”,
“文件加载器”:“^1.1.11”,
“flexboxgrid”:“^6.3.1”,
“git挂钩”:“^1.1.10”,
“历史记录”:“^4.7.2”,
“html网页包插件”:“^3.0.6”,
“笑话”:“^22.4.2”,
“lodash”:“^4.17.10”,
“节点sass”:“^4.7.2”,
“regexp的路径”:“^2.2.0”,
“拉姆达”:“^0.25.0”,
“反应”:“^16.2.0”,
“react dom”:“^16.2.0”,
“反应热加载程序”:“^4.0.0”,
“react redux”:“^5.0.7”,
“反应路由器”:“^4.2.0”,
“反应路由器dom”:“^4.2.2”,
“react router redux”:“^4.0.8”,
“react sortable hoc”:“^0.6.8”,
“反应测试渲染器”:“^16.3.2”,
“redux”:“^3.7.2”,
“redux模拟商店”:“^1.5.1”,
“redux thunk”:“^2.2.0”,
“rest”:“^2.0.0”,
“sass lint”:“^1.12.1”,
“sass加载程序”:“^6.0.7”,
“样式加载器”:“^0.20.2”,
“svg内联加载程序”:“^0.8.0”,
“svg加载程序”:“^0.0.2”,
“url加载程序”:“^1.0.1”,
“网页包”:“^4.20.2”,
“webpack cli”:“^2.0.10”,
“网页包开发服务器”:“2.11.1”
}
}

您需要做两件事:

  • 除去webpack@4.20.2及网页-cli@2.0.10依赖项,并专门安装webpack@4.19.0及网页-cli@3.0.4版本网页包
  • 也不要使用
    提取文本网页包插件
  • 提取文本网页包插件
    不应与网页包4一起用于提取CSS。它不起作用。请尝试使用:

    在这些更改之后,webpack应该编译您的代码并生成必要的包


    注意:当我在系统上克隆上述存储库时,我必须对
    board.js
    文件进行更改。我对这个导入语句进行了更改:
    import CoinMarketCap from'components/Partials/CoinMarketCap/link'这在Linux系统上不起作用,因为路径区分大小写。

    尝试安装最新版本的节点,然后再次测试。最新的LTS节点和npm对我来说效果非常好。

    如果在更新npm软件包后发生这种情况,请删除并重新安装webpack webpack cli
    npm删除网页包webpack cli

    npm安装--保存开发人员网页包webpack cli


    我建议您在执行任何操作之前升级/更新节点。

    它是“webpack cli”中的^符号“^2.0.10”依赖项,导致次要/修补程序版本升级到最新的webpack-cli@2.x.x,它有以下变化

    导致问题的网页包更改:(将输出更改为输出) 参考:

    解决方案:(安装网页包)-cli@3.x.x)

    npm卸载网页包cli

    npm安装--保存开发人员网页包-cli@3.1.1


    REF:

    迁移到最新版本为我解决了错误:webpack cli^3.3.11

    对我来说效果很好,您能否澄清哪个脚本出现了错误?您使用什么节点和npm版本?一般来说,再现错误前的步骤是什么?我尝试了开发和构建。工作正常。@KarenGrigoryan节点:
    v10.8.0
    npm
    6.4.1
    然后等待您下载了repo,它构建并运行正常?哪个分支?确切地说,分支是dev。我98%确定它是节点。尝试安装节点v8.12.0的最新LTS版本并检查