Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/376.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 抛出新错误(`Deprecation notice:CommonChunkPlugin现在只接受一个参数 我正在尝试使用webpack构建我的angular应用程序 所以我引用了这个链接 我在package.json级别创建了一个webpack.config.js,并在package.json中包含了这行“bundle”:“webpack” 当我运行npm run bundle时,我遇到一个错误npm ERR!在sleeping@1.0.0捆绑脚本“webpack” 你能告诉我怎么修吗 在下面提供我的代码和eror_Javascript_Angular_Typescript_Npm_Webpack - Fatal编程技术网

Javascript 抛出新错误(`Deprecation notice:CommonChunkPlugin现在只接受一个参数 我正在尝试使用webpack构建我的angular应用程序 所以我引用了这个链接 我在package.json级别创建了一个webpack.config.js,并在package.json中包含了这行“bundle”:“webpack” 当我运行npm run bundle时,我遇到一个错误npm ERR!在sleeping@1.0.0捆绑脚本“webpack” 你能告诉我怎么修吗 在下面提供我的代码和eror

Javascript 抛出新错误(`Deprecation notice:CommonChunkPlugin现在只接受一个参数 我正在尝试使用webpack构建我的angular应用程序 所以我引用了这个链接 我在package.json级别创建了一个webpack.config.js,并在package.json中包含了这行“bundle”:“webpack” 当我运行npm run bundle时,我遇到一个错误npm ERR!在sleeping@1.0.0捆绑脚本“webpack” 你能告诉我怎么修吗 在下面提供我的代码和eror,javascript,angular,typescript,npm,webpack,Javascript,Angular,Typescript,Npm,Webpack,文件夹结构 - webapp - app - app.module.ts - package.json -webpack.config.js 应用程序模块.ts import './rxjs-extensions'; import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule,Re

文件夹结构

- webapp
  - app
    - app.module.ts
  - package.json
  -webpack.config.js
应用程序模块.ts

import './rxjs-extensions';

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule,ReactiveFormsModule }   from '@angular/forms';
import { HttpModule }    from '@angular/http';
import { AppComponent }         from './app.component';

import {Base} from './components/base/base';
import {players} from './components/jumping/user';

require('./directives/yep-nope.controller');
require('./services/github-status.service');
require('./controllers/dashboard.controller');

import {
    Routes,
    RouterModule,
    Router,
    ActivatedRoute,

    CanActivateChild,
    CanDeactivate,
    ActivatedRouteSnapshot,
    RouterStateSnapshot
} from "@angular/router";


@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
  ReactiveFormsModule,
    HttpModule,
    routing,
    MultiselectDropdownModule,
    AccordionModule
  ],
  declarations: [
    AppComponent,
  Base,
  jumping,
  players
  ],
  providers: [
  SPORTSService],
  bootstrap: [ AppComponent ]
})
export class AppModule {
}
var webpack = require('webpack');
module.exports = {
    context: __dirname + '/app',
        entry: {
            app: './app.js',
            vendor: ['angular']
        },
        output: {
            path: __dirname + '/js',
            filename: 'app.bundle.js'
        },
        plugins: [
            new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.bundle.js")
        ]
    };
package.json

{
  "name": "SPORTS",
  "version": "1.0.0",
  "scripts": {
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings",
    "test": "tsc && concurrently \"karma start karma.conf.js\"",
    "bundle": "webpack"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/common": "2.0.0",
    "@angular/compiler": "2.0.0",
    "@angular/core": "2.0.0",
    "@angular/forms": "2.0.0",
    "@angular/http": "2.0.0",
    "@angular/platform-browser": "2.0.0",
    "@angular/platform-browser-dynamic": "2.0.0",
    "@angular/router": "3.0.0",
    "@angular/upgrade": "2.0.0",
    "@types/underscore": "^1.8.1",
    "angular2-in-memory-web-api": "0.0.20",
    "bootstrap": "^3.3.6",
    "core-js": "^2.4.1",
    "jquery": "^3.1.1",
    "latest-version": "^2.0.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.12",
    "systemjs": "0.19.27",
    "zone.js": "^0.6.23"
  },
  "devDependencies": {
    "concurrently": "^2.2.0",
    "jasmine-core": "~2.4.1",
    "jasmine-expect": "^3.0.1",
    "jasmine-jquery": "^2.1.1",
    "karma": "^1.2.0",
    "karma-chrome-launcher": "^0.2.3",
    "karma-cli": "^0.1.2",
    "karma-coverage": "^1.1.1",
    "karma-htmlfile-reporter": "^0.2.2",
    "karma-jasmine": "^0.3.8",
    "karma-jquery": "^0.1.0",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-typescript": "^2.1.4",
    "karma-typescript-preprocessor": "^0.3.0",
    "lite-server": "^2.2.2",
    "typescript": "^2.0.2",
    "typings": "^1.3.2",
    "webpack": "^3.7.1"
  }
}
webpack.config.js

import './rxjs-extensions';

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule,ReactiveFormsModule }   from '@angular/forms';
import { HttpModule }    from '@angular/http';
import { AppComponent }         from './app.component';

import {Base} from './components/base/base';
import {players} from './components/jumping/user';

require('./directives/yep-nope.controller');
require('./services/github-status.service');
require('./controllers/dashboard.controller');

import {
    Routes,
    RouterModule,
    Router,
    ActivatedRoute,

    CanActivateChild,
    CanDeactivate,
    ActivatedRouteSnapshot,
    RouterStateSnapshot
} from "@angular/router";


@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
  ReactiveFormsModule,
    HttpModule,
    routing,
    MultiselectDropdownModule,
    AccordionModule
  ],
  declarations: [
    AppComponent,
  Base,
  jumping,
  players
  ],
  providers: [
  SPORTSService],
  bootstrap: [ AppComponent ]
})
export class AppModule {
}
var webpack = require('webpack');
module.exports = {
    context: __dirname + '/app',
        entry: {
            app: './app.js',
            vendor: ['angular']
        },
        output: {
            path: __dirname + '/js',
            filename: 'app.bundle.js'
        },
        plugins: [
            new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.bundle.js")
        ]
    };
错误

$ npm run bundle
$npm运行包

> sports@1.0.0 bundle C:\Users\webcomponent\src\main\webapp
> webpack

C:\Users\webcomponent\src\main\webapp\node_modules\webpack\lib\optimize\CommonsChunkPlugin.js:11
                        throw new Error(`Deprecation notice: CommonsChunkPlugin now only takes a single argument. Either an options
                        ^

Error: Deprecation notice: CommonsChunkPlugin now only takes a single argument. Either an options
object *or* the name of the chunk.
Example: if your old code looked like this:
        new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js')
You would change it to:
        new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.bundle.js' })
The available options are:
        name: string
        names: string[]
        filename: string
        minChunks: number
        chunks: string[]
        children: boolean
        async: boolean
        minSize: number
    at new CommonsChunkPlugin (C:\Users\webcomponent\src\main\webapp\node_modules\webpack\lib\optimize\CommonsChunkPlugin.js:11:10)
    at Object.<anonymous> (C:\Users\webcomponent\src\main\webapp\webpack.config.js:13:13)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at requireConfig (C:\Users\webcomponent\src\main\webapp\node_modules\webpack\bin\convert-argv.js:97:18)

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "bundle"
npm ERR! node v6.11.2
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! sports@1.0.0 bundle: `webpack`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sports@1.0.0 bundle script 'webpack'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sports package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     webpack
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs sports
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls sports
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\webcomponent\src\main\webapp\npm-debug.log
>sports@1.0.0捆绑包C:\Users\webcomponent\src\main\webapp
>网页包
C:\Users\webcomponent\src\main\webapp\node\u modules\webpack\lib\optimize\CommonsChunkPlugin.js:11
抛出新错误(`Deprecation notice:CommonChunkPlugin现在只接受一个参数。选项
^
错误:弃用通知:CommonChunkPlugin现在只接受一个参数。选项
对象*或*块的名称。
示例:如果旧代码如下所示:
新建webpack.optimize.commonChunkPlugin('vendor','vendor.bundle.js'))
您可以将其更改为:
新建webpack.optimize.commonChunkPlugin({name:'vendor',filename:'vendor.bundle.js'})
可供选择的方案有:
名称:string
名称:字符串[]
文件名:字符串
minChunks:数字
块:字符串[]
子项:布尔值
异步:布尔
minSize:数字
在新的CommonChunkPlugin(C:\Users\webcomponent\src\main\webapp\node\u modules\webpack\lib\optimize\commonChunkPlugin.js:11:10)
at对象。(C:\Users\webcomponent\src\main\webapp\webpack.config.js:13:13)
在模块处编译(Module.js:570:32)
在Object.Module.\u extensions..js(Module.js:579:10)
在Module.load(Module.js:487:32)
在tryModuleLoad时(module.js:446:12)
在Function.Module.\u加载(Module.js:438:3)
at Module.require(Module.js:497:17)
根据需要(内部/module.js:20:19)
at requireConfig(C:\Users\webcomponent\src\main\webapp\node\u modules\webpack\bin\convert argv.js:97:18)
npm错误!Windows\u NT 10.0.14393
npm ERR!argv“C:\\Program Files\\nodejs\\node.exe”“C:\\Program Files\\nodejs\\nodejs\U模块\\npm\\bin\\npm cli.js”“运行”“捆绑”
npm错误!节点v6.11.2
npm ERR!npm v3.10.10
npm错误!代码错误周期
npm错误!sports@1.0.0bundle:`webpack`
npm错误!退出状态1
npm错误!
npm ERR!在以下位置失败:sports@1.0.0捆绑脚本“webpack”。
npm错误!请确保已安装最新版本的node.js和npm。
npm ERR!如果你这样做,这很可能是运动套餐的问题,
npm错误!与npm本身无关。
npm ERR!告诉作者此操作在您的系统上失败:
npm错误!网页包
npm ERR!您可以通过以下方式获取有关如何打开此项目问题的信息:
npm错误!npm错误运动
npm ERR!如果不可用,您可以通过以下方式获取他们的信息:
npm错误!npm所有者ls sports
npm ERR!上面可能还有其他日志输出。
npm ERR!请在任何支持请求中包含以下文件:
npm ERR!C:\Users\webcomponent\src\main\webapp\npm-debug.log

webpack.config.js
中,您应该更改以下内容:

new webpack.optimize.CommonsChunkPlugin(
    /* chunkName= */"vendor", /* filename= */"vendor.bundle.js")
致:


这应该行得通。

a)
sleeping
1.0.0版不存在:;b)您是否在正确的位置有“webpack.config.js”文件?(
当前目录中的配置文件可能名为“webpack.config.js”。
)@另一个人上传了文件夹结构…你能告诉我我是否完成了吗properly@another-盖伊嘿谢谢你的回复…更新了正确的错误…你现在能帮我吗