2017-03-29 5 views
0

내가 webpack 2typescript 2.2.2babel 로더를 사용하고 node_modules을 제외하려고 노력하지만, webpack 명령을하려고 할 때 여전히 node_modules에 angular 4.0.0에서 오류를 얻을 작동하지 node_modules을 제외 할 수 있습니다.웹팩 2 TS-로더

webpack.congfig.js : 웹팩 --progress 명령 후

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

var PROD = true; 

    module.exports = { 
     entry: path.join(__dirname, 'ng2', 'src','index.js'), 
     output: { 
      path: path.join(__dirname, 'ng2', 'dist'), 
      filename: 'vendorNG2.js' 
     }, 
     devtool: 'eval', 
     resolve: { 
      extensions: [".tsx", ".ts", ".js"] 
     }, 
     watch: true, 
     module: { 
      rules: [ 
       { 
        test: /\.tsx?$/, 
        loader: 'ts-loader', 
        exclude: [/node_modules/], 
       }, 
       { 
        test: /\.js$/, 
        exclude: [/node_modules/], 
        use: { 

         loader: "babel-loader?cacheDirectory=true", 
         options: { 
          presets: ['es2015'] 
         } 
        } 
       }, 
      ] 
     }, 
     plugins: PROD ? [ 
      new webpack.optimize.UglifyJsPlugin({ 
       compress: { warnings: false } 
      }) 
     ] : [] 
    } 

:

... 
ERROR in /home/user/Projects/project/front/node_modules/angular2/src/facade/lang.d.ts 
(13,17): error TS2693: 'Map' only refers to a type, but is being used as a value here. 

ERROR in /home/user/Projects/project/front/node_modules/angular2/src/facade/lang.d.ts 
(14,17): error TS2693: 'Set' only refers to a type, but is being used as a value here. 

ERROR in ./ng2/src/app/main.ts 
(19,14): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning. 

당신은 오류가 node_modules에서 오는 볼 수 있습니다.

tsconfig.json의 v1의

{ 
    "compilerOptions": { 
    "outDir": "./dist/", 
    "sourceMap": true, 
    "noImplicitAny": true, 
    "module": "commonjs", 
    "target": "es5", 
    "jsx": "react", 
    "allowJs": true 
    } 
} 

tsconfig.json v2를 :

{ 
    "compilerOptions": { 
    "outDir": "./ng2/dist/", 
    "sourceMap": true, 
    "noImplicitAny": true, 
    "module": "commonjs", 
    "target": "es5", 
    "jsx": "react", 
    "type":[], 
    "allowJs": true 
    }, 
    "exclude": [ 
    "node_modules" 
    ] 
} 

V2 오류 :

ERROR in /home/user/Projects/project/front/admin/tsconfig.json 
error TS5023: Unknown compiler option 'type'. 
@ ./ng2/src/index.js 8:0-21 

ERROR in ./ng2/src/app/main.ts 
Module build failed: error while parsing tsconfig.json 
@ ./ng2/src/index.js 8:0-21 

tsconfig.js 추가 v3의 ("experimentalDecorators을"참) 몇 가지 오류가 발생했습니다.

{ 
    "compilerOptions": { 
    "outDir": "./ng2/dist/", 
    "sourceMap": true, 
    "noImplicitAny": true, 
    "module": "commonjs", 
    "target": "es5", 
    "jsx": "react", 
    "experimentalDecorators": true, 
    "allowJs": true 
    }, 
    "exclude": [ 
    "node_modules" 
    ] 
} 

V3 오류 :

... /home/user/Projects/project/front/node_modules/angular2/src/facade/lang.d.ts 에서 ERROR (13, 17) : 오류 TS2693 : '지도'는 유형을 나타낼 뿐이며 여기서 값으로 사용됩니다. /home/user/Projects/project/front/node_modules/angular2/src/facade/lang.d.ts 에서

ERROR (14,17) : 오류 TS2693 '설정은'만 형태를 의미하지만, 여기서 값으로 사용됩니다.

+0

'tsconfig' 모양이 어떻게됩니까? – tymeJV

+0

업데이트 된 소식 –

+0

'experimentalDecorators : true'를'tsconfig'에 추가하려고 했습니까?- 그들이 작동하지 않는다면, "유형"을 추가하십시오 : []' – tymeJV

답변

1

tsconfig에 node_modules를 제외 시켰습니까?

{ 
    "compilerOptions": { 
    "outDir": "./dist/", 
    "sourceMap": true, 
    "noImplicitAny": true, 
    "module": "commonjs", 
    "target": "es5", 
    "jsx": "react", 
    "allowJs": true 
    }, 
    "exclude": [ 
    "node_modules" 
    ] 
} 

또한 사용중인 Typescript 및 Angular의 버전을 지정하지 않았습니다.

편집 : 질문을 업데이트하여 각도 4를 사용한다고 지정했지만 업데이트 된 오류는 옳지 않은 node_modules/angular2/폴더를 표시합니다. 계속하기 전에 node_modules 폴더를 삭제하고 npm install을 다시 실행하십시오.

그렇지 않으면 타이핑 문제가있는 것처럼 보입니다. @ 유형이 모두 설치되어 있습니까? 여기

내 tsconfig.json이 설정 방법의 예입니다

{ 
    "compilerOptions": { 
     "target": "ES5", 
     "module": "commonjs", 
     "moduleResolution": "node", 
     "sourceMap": true, 
     "emitDecoratorMetadata": true, 
     "experimentalDecorators": true, 
     "lib": [ "es2015", "dom" ], 
     "removeComments": false, 
     "noImplicitAny": false, 
     "types": [ "jasmine", "lodash", "core-js" ], 
     "typeRoots": [ 
      "../node_modules/@types" 
     ] 
    }, 
    "exclude": [ 
     "node_modules", 
     "wwwroot", 
     "temp" 
    ] 
} 

내 node_modules 폴더가 상위 디렉토리에, 그래서 나는 typeRoots에 그를 지정합니다. 다음과 같은 유형도 설치되어 있습니다.

"@types/core-js": "0.9.37", 
"@types/jasmine": "2.5.43", 
"@types/lodash": "4.14.55", 
+1

" "제외": [ "node_modules" ] 작동 –

+0

질문이 업데이트되었음을 ​​확인한 후 답변이 업데이트되었습니다. – Stout01