2017-12-06 3 views
0

Visual Studio 2017 버전 15.4.5를 사용하여 Windows 7 Professional PC를 실행하고 있습니다. .Net Core 2.0 프로젝트를 만들고 Angular의 유형을 선택했을 때, 그것은 괜찮 았어.Visual Studio 2017 .Net Core 2.0 각도 게시 실패

다음은 표준 방법 인 font.wesome 및 primeng (https://www.primefaces.org/primeng/#/)을 추가했습니다. 즉, package.json 파일에 대한 참조를 추가 한 다음 webpack.config.vendor.js 파일의 nonTreeShakableModules 섹션에 추가합니다. app.module.shared.ts에 모듈을 추가합니다. 이것은 primeng 버전 5.0.2와 font-awesome 버전 4.7.0이었습니다.

개발 중 모두 훌륭합니다. 모든 것이 잘 돌아갑니다.

npm install 
removed 3 packages in 3.389s 
node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod 

무엇 : 나는 게시 할 때, 나는 출력 창에 다음 줄을 볼? 이유가 그것이 3 팩을 제거?

게시 시도가 실패합니다. 실패 후, 나는 내 NPM 패키지 (3)이 제거 된 것을 볼 수 : 1) 유형/JQuery와 2) 글꼴 최고 3 가)

을 primeng 내가 "모듈을 찾을 수 없습니다"오류의 무리를 볼 @ - 그들은 단지 이 제거 되었기 때문에 물론 발견되지 않았습니다!

은 내가 .csproj 파일 보았다, 나는 다음을 참조 :

<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish"> 
    <!-- As part of publishing, ensure the JS resources are freshly built in production mode --> 
    <Exec Command="npm install" /> 
    <Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" /> 
    <Exec Command="node node_modules/webpack/bin/webpack.js --env.prod" /> 

그래서, 지금까지 내가 말할 수있는, 명령, 또는 명령에 의해 트리거 무언가가있다 "NPM 설치" 이러한 모듈을 제거합니다. 모든 게시 시도 후에 다시 설치해야합니다.

내 질문 : 왜 이러한 패키지가 제거되고 있으며 어떻게해야합니까?

내 package.json 파일 :

{ 
    "name": "CaseManagementReporting", 
    "private": true, 
    "version": "0.0.0", 
    "scripts": { 
     "test": "karma start ClientApp/test/karma.conf.js" 
    }, 
    "dependencies": { 
     "@angular/animations": "4.2.5", 
     "@angular/common": "4.2.5", 
     "@angular/compiler": "4.2.5", 
     "@angular/compiler-cli": "4.2.5", 
     "@angular/core": "4.2.5", 
     "@angular/forms": "4.2.5", 
     "@angular/http": "4.2.5", 
     "@angular/platform-browser": "4.2.5", 
     "@angular/platform-browser-dynamic": "4.2.5", 
     "@angular/platform-server": "4.2.5", 
     "@angular/router": "4.2.5", 
     "@ngtools/webpack": "1.5.0", 
     "@types/webpack-env": "1.13.0", 
     "angular2-template-loader": "0.6.2", 
     "aspnet-prerendering": "^3.0.1", 
     "aspnet-webpack": "^2.0.1", 
     "awesome-typescript-loader": "3.2.1", 
     "bootstrap": "3.3.7", 
     "css": "2.2.1", 
     "css-loader": "0.28.4", 
     "es6-shim": "0.35.3", 
     "event-source-polyfill": "0.0.9", 
     "expose-loader": "0.7.3", 
     "extract-text-webpack-plugin": "2.1.2", 
     "file-loader": "0.11.2", 
     "font-awesome": "4.7.0", 
     "html-loader": "0.4.5", 
     "isomorphic-fetch": "2.2.1", 
     "jquery": "3.2.1", 
     "json-loader": "0.5.4", 
     "preboot": "4.5.2", 
     "primeng": "5.0.2", 
     "raw-loader": "0.5.1", 
     "reflect-metadata": "0.1.10", 
     "rxjs": "5.4.2", 
     "style-loader": "0.18.2", 
     "to-string-loader": "1.1.5", 
     "typescript": "2.4.1", 
     "url-loader": "0.5.9", 
     "webpack": "2.5.1", 
     "webpack-hot-middleware": "2.18.2", 
     "webpack-merge": "4.1.0", 
     "zone.js": "0.8.12" 
    }, 
    "devDependencies": { 
     "@types/chai": "4.0.1", 
     "@types/jasmine": "2.5.53", 
     "@types/jquery": "3.2.1", 
     "chai": "4.0.2", 
     "jasmine-core": "2.6.4", 
     "karma": "1.7.0", 
     "karma-chai": "0.1.0", 
     "karma-chrome-launcher": "2.2.0", 
     "karma-cli": "1.0.1", 
     "karma-jasmine": "1.1.0", 
     "karma-webpack": "2.0.3" 
    } 
} 

내 tsconfig.json 파일 :

{ 
    "compilerOptions": { 
    "module": "es2015", 
    "moduleResolution": "node", 
    "target": "es5", 
    "sourceMap": true, 
    "experimentalDecorators": true, 
    "emitDecoratorMetadata": true, 
    "skipDefaultLibCheck": true, 
    "skipLibCheck": true, // Workaround for https://github.com/angular/angular/issues/17863. Remove this if you upgrade to a fixed version of Angular. 
    "strict": true, 
    "lib": [ "es6", "dom" ], 
    "types": [ "webpack-env", "jquery" ] 
    }, 
    "exclude": [ "bin", "node_modules" ], 
    "atom": { "rewriteTsconfig": false } 
} 

내 webpack.config.vendor.js 파일 :

const path = require('path'); 
const webpack = require('webpack'); 
const ExtractTextPlugin = require('extract-text-webpack-plugin'); 
const merge = require('webpack-merge'); 
const treeShakableModules = [ 
    '@angular/animations', 
    '@angular/common', 
    '@angular/compiler', 
    '@angular/core', 
    '@angular/forms', 
    '@angular/http', 
    '@angular/platform-browser', 
    '@angular/platform-browser-dynamic', 
    '@angular/router', 
    'zone.js' 
]; 

const nonTreeShakableModules = [ 
    'bootstrap', 
    'bootstrap/dist/css/bootstrap.css', 
    'es6-promise', 
    'es6-shim', 
    'event-source-polyfill', 
    'jquery', 
    'font-awesome/css/font-awesome.css', 
    'primeng/resources/themes/bootstrap/theme.css', 
    'primeng/resources/primeng.min.css', 
    'primeng/primeng' 
]; 
const allModules = treeShakableModules.concat(nonTreeShakableModules); 

module.exports = (env) => { 
    const extractCSS = new ExtractTextPlugin('vendor.css'); 
    const isDevBuild = !(env && env.prod); 
    const sharedConfig = { 
     stats: { modules: false }, 
     resolve: { extensions: [ '.js' ] }, 
     module: { 
      rules: [ 
       { test: /\.(png|woff|woff2|eot|ttf|svg|jpg|jpeg|gif)(\?|$)/, use: 'url-loader?limit=100000' } 
      ] 
     }, 
     output: { 
      publicPath: 'dist/', 
      filename: '[name].js', 
      library: '[name]_[hash]' 
     }, 
     plugins: [ 
      new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable) 
      new webpack.ContextReplacementPlugin(/\@angular\b.*\b(bundles|linker)/, path.join(__dirname, './ClientApp')), // Workaround for https://github.com/angular/angular/issues/11580 
      new webpack.ContextReplacementPlugin(/angular(\\|\/)core(\\|\/)@angular/, path.join(__dirname, './ClientApp')), // Workaround for https://github.com/angular/angular/issues/14898 
      new webpack.IgnorePlugin(/^vertx$/) // Workaround for https://github.com/stefanpenner/es6-promise/issues/100 
     ] 
    }; 

    const clientBundleConfig = merge(sharedConfig, { 
     entry: { 
      // To keep development builds fast, include all vendor dependencies in the vendor bundle. 
      // But for production builds, leave the tree-shakable ones out so the AOT compiler can produce a smaller bundle. 
      vendor: isDevBuild ? allModules : nonTreeShakableModules 
     }, 
     output: { path: path.join(__dirname, 'wwwroot', 'dist') }, 
     module: { 
      rules: [ 
       { test: /\.css(\?|$)/, use: extractCSS.extract({ use: isDevBuild ? 'css-loader' : 'css-loader?minimize' }) } 
      ] 
     }, 
     plugins: [ 
      extractCSS, 
      new webpack.DllPlugin({ 
       path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'), 
       name: '[name]_[hash]' 
      }) 
     ].concat(isDevBuild ? [] : [ 
      new webpack.optimize.UglifyJsPlugin() 
     ]) 
    }); 

    const serverBundleConfig = merge(sharedConfig, { 
     target: 'node', 
     resolve: { mainFields: ['main'] }, 
     entry: { vendor: allModules.concat(['aspnet-prerendering']) }, 
     output: { 
      path: path.join(__dirname, 'ClientApp', 'dist'), 
      libraryTarget: 'commonjs2', 
     }, 
     module: { 
      rules: [ 
       { test: /\.css(\?|$)/, use: ['to-string-loader', isDevBuild ? 'css-loader' : 'css-loader?minimize'] } 
      ] 
     }, 
     plugins: [ 
      new webpack.DllPlugin({ 
       path: path.join(__dirname, 'ClientApp', 'dist', '[name]-manifest.json'), 
       name: '[name]_[hash]' 
      }) 
     ] 
    }); 

    return [clientBundleConfig, serverBundleConfig]; 
} 

내 웹팩. config.js 파일 :

const path = require('path'); 
const webpack = require('webpack'); 
const merge = require('webpack-merge'); 
const AotPlugin = require('@ngtools/webpack').AotPlugin; 
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin; 

module.exports = (env) => { 
    // Configuration in common to both client-side and server-side bundles 
    const isDevBuild = !(env && env.prod); 
    const sharedConfig = { 
     stats: { modules: false }, 
     context: __dirname, 
     resolve: { extensions: [ '.js', '.ts' ] }, 
     output: { 
      filename: '[name].js', 
      publicPath: 'dist/' // Webpack dev middleware, if enabled, handles requests for this URL prefix 
     }, 
     module: { 
      rules: [ 
       { test: /\.ts$/, include: /ClientApp/, use: isDevBuild ? ['awesome-typescript-loader?silent=true', 'angular2-template-loader'] : '@ngtools/webpack' }, 
       { test: /\.html$/, use: 'html-loader?minimize=false' }, 
       { test: /\.css$/, use: [ 'to-string-loader', isDevBuild ? 'css-loader' : 'css-loader?minimize' ] }, 
       { test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' } 
      ] 
     }, 
     plugins: [new CheckerPlugin()] 
    }; 

    // Configuration for client-side bundle suitable for running in browsers 
    const clientBundleOutputDir = './wwwroot/dist'; 
    const clientBundleConfig = merge(sharedConfig, { 
     entry: { 'main-client': './ClientApp/boot.browser.ts' }, 
     output: { path: path.join(__dirname, clientBundleOutputDir) }, 
     plugins: [ 
      new webpack.DllReferencePlugin({ 
       context: __dirname, 
       manifest: require('./wwwroot/dist/vendor-manifest.json') 
      }) 
     ].concat(isDevBuild ? [ 
      // Plugins that apply in development builds only 
      new webpack.SourceMapDevToolPlugin({ 
       filename: '[file].map', // Remove this line if you prefer inline source maps 
       moduleFilenameTemplate: path.relative(clientBundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk 
      }) 
     ] : [ 
      // Plugins that apply in production builds only 
      new webpack.optimize.UglifyJsPlugin(), 
      new AotPlugin({ 
       tsConfigPath: './tsconfig.json', 
       entryModule: path.join(__dirname, 'ClientApp/app/app.module.browser#AppModule'), 
       exclude: ['./**/*.server.ts'] 
      }) 
     ]) 
    }); 

    // Configuration for server-side (prerendering) bundle suitable for running in Node 
    const serverBundleConfig = merge(sharedConfig, { 
     resolve: { mainFields: ['main'] }, 
     entry: { 'main-server': './ClientApp/boot.server.ts' }, 
     plugins: [ 
      new webpack.DllReferencePlugin({ 
       context: __dirname, 
       manifest: require('./ClientApp/dist/vendor-manifest.json'), 
       sourceType: 'commonjs2', 
       name: './vendor' 
      }) 
     ].concat(isDevBuild ? [] : [ 
      // Plugins that apply in production builds only 
      new AotPlugin({ 
       tsConfigPath: './tsconfig.json', 
       entryModule: path.join(__dirname, 'ClientApp/app/app.module.server#AppModule'), 
       exclude: ['./**/*.browser.ts'] 
      }) 
     ]), 
     output: { 
      libraryTarget: 'commonjs', 
      path: path.join(__dirname, './ClientApp/dist') 
     }, 
     target: 'node', 
     devtool: 'inline-source-map' 
    }); 

    return [clientBundleConfig, serverBundleConfig]; 
}; 

답변

0

이 문제에 대한 해결책을 찾았습니다 (슬프게도 다른 문제를 일으켰지 만 ...).

나는 이것이/사용하고있는 NPM 버전의 버그라고 생각합니다. npm 버전 5.0.3이 설치되었습니다. 몇 시간 동안 검색을 해본 결과,이 GitHub 토론을 보았습니다 :많은 사람들이 실제로 모듈을 제거하는 npm install 명령에 대해 불평을합니다. 내 npm 인스턴스를 5.0.3에서 3.10.3으로 다운 그레이드했는데 (집 환경이 사용하고있는 것임), 패키지가 더 이상 제거되지 않은 것으로 나타났습니다. (왜 누군가가 "npm install"과 같은 명령을 사용하여 패키지를 제거 할 수있는 글을 쓸 수 없지만 링크 된 기사를 읽으면 이것이 야기한 좌절을 볼 수 있습니다!)

a.닷넷 개발자 물론, 난 내 NPM 인스턴스를 다운 그레이드하는 방법을 알고하지 않았다, 그래서 나는 그을 지켜 볼 수밖에 없었습니다. 도움을받을 수있는 사람들은 npm install -g [email protected] 명령을 사용하십시오. https://github.com/expo/expo/issues/297

그래서, 지금 게시의 나 프로세스가 내 질문에 대해 무엇을 요구하다, 삭제 패키지없이 실행 : 여기 것을 발견했다. 이 문제는 해결되었으므로이를 답변으로 취급하고 있습니다.

는하지만이 다운 그레이드 내 모든 문제를 해결한다는 말은 아니다. 게시를 시도 할 때 npm 버전과 관련이없는 새로운 오류가 발생했습니다.

'./../$$_gendir/ClientApp/app/app.module.browser.ngfactory를 해결할 수 없습니다. 'C : \ Projects \ FrightProjects \ CaseManagementReporting \ CaseManagementReporting \ ClientApp'CaseManagementReporting 모듈을 찾을 수 없음 0

'해결할 수 없습니다 ./../$$_gendir/ClientApp/app/app.module.server.ngfactory C '에서'https://github.com/aspnet/JavaScriptServices/issues/1168 공동 제안 : 프로젝트 \ \ ForthrightProjects \ CaseManagementReporting \ CaseManagementReporting은을 ClientApp 'CaseManagementReporting 모듈 \

인터넷 검색이 문서를 발견하지만 더 공을 찾을 수 없습니다 webpack.config.js 파일에서이 행을 작성하십시오.

// {test : /.ts$/, include :/ClientApp /, use : isDevBuild? [ 'nesools-loader'] : '@ ngtools/webpack'},

{테스트 :/.ts $ /, include :/ClientApp /, 사용 : [ 'awesome-typescript-loader? silent = true', 'angular2-template-loader']},

두 옵션을 모두 사용해 보았고 위의 오류를 지나쳐라. 그러나, 나는 지금 게시 시도에 또 다른 오류에 직면하고있다 : ERROR 메타 데이터 버전 불일치에 모듈 : C : /Projects/ForthrightProjects/CaseManagementReporting/CaseManagementReporting/node_modules/primeng/components/dom/domhandler.d.ts 발견 버전 4, 예상 됨 3

추가 검색 및 시행 착오를 거쳐이 링크를 발견했습니다. https://github.com/primefaces/primeng/issues/4401 project.json 파일의 primeng 항목을 다음과 같이 변경하는 것이 좋습니다. "primeng ":"^ 4.2.4 "

충분히 굉장이 실제로했다. 이제 게시 할 수있게되었습니다. 퍼블리시 된 파일의 성공적인 배포가 그리 고통스럽지는 않을 것입니다.

. 닷넷 개발자 : 방금 NuGet을 사용하여 패키지를 추가 할 때 다시 기억하십시오. 한숨 ...