在Meteor 1.6服务器和服务器之间共享`node_modules`。 Angular CLI客户端Angular-Meteor子项目?

时间:2017-11-03 11:43:40

标签: meteor angular-cli angular-meteor

我在Angular-Meteor项目中使用Meteor 1.3.x-1.5.x作为服务器,并通过Angular CLI构建了Web客户端。直到Meteor 1.6,我已经能够使用通过符号链接共享的单个node_modules目录来减少客户端和服务器之间的许多共享依赖关系的大小并轻松保持同步,遵循Angular的示例 - 流星启动器应用程序。

但是,从服务器目录根目录中出现的新package-lock.json文件开始,Meteor 1.6似乎在node_modules中安装了自己的依赖项,包括许多@angular/*依赖项,这导致由于多个冲突的软件包安装,我得到以下错误。有什么建议吗?

```
ERROR in ./clients/browser/main.ts
Module build failed: Error: Angular Compiler was detected but it was an instance of the wrong class.
This likely means you have several @ngtools/webpack packages installed. You can check this with `npm ls @ngtools/webpack`, and then remove the extra copies.
at Object.ngcLoader (/Users/keith.gillette/Code/TaskTrain/node_modules/@ngtools/webpack/src/loader.js:458:19)
@ multi webpack-dev-server/client?http://0.0.0.0:0 ./clients/browser/main.ts

ERROR in ./clients/browser/polyfills.ts
Module build failed: Error: Angular Compiler was detected but it was an instance of the wrong class.
This likely means you have several @ngtools/webpack packages installed. You can check this with `npm ls @ngtools/webpack`, and then remove the extra copies.
at Object.ngcLoader (/Users/keith.gillette/Code/TaskTrain/node_modules/@ngtools/webpack/src/loader.js:458:19)
@ multi ./clients/browser/polyfills.ts

ERROR in Error: Error encountered resolving symbol values statically. 
 Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 194:50 in the original .ts file), resolving symbol NgModule in .../node_modules/ng-http-loader/node_modules/@angular/core/core.d.ts, resolving symbol NgHttpLoaderModule in .../node_modules/ng-http-loader/ng-http-loader.module.d.ts, resolving symbol NgHttpLoaderModule in .../node_modules/ng-http-loader/ng-http-loader.module.d.ts
at positionalError (.../node_modules/@angular/compiler/bundles/compiler.umd.js:25134:35)
at simplifyInContext (.../node_modules/@angular/compiler/bundles/compiler.umd.js:24977:27)
at StaticReflector.simplify (.../node_modules/@angular/compiler/bundles/compiler.umd.js:24991:13)
at StaticReflector.annotations (.../node_modules/@angular/compiler/bundles/compiler.umd.js:24418:41)
at _getNgModuleMetadata (../node_modules/@angular/compiler-cli/src/ngtools_impl.js:138:31)
at _extractLazyRoutesFromStaticModule (.../node_modules/@angular/compiler-cli/src/ngtools_impl.js:109:26)
at .../node_modules/@angular/compiler-cli/src/ngtools_impl.js:129:27
at Array.reduce (native)
at _extractLazyRoutesFromStaticModule (.../node_modules/@angular/compiler-cli/src/ngtools_impl.js:128:10)
at Object.listLazyRoutesOfModule (.../node_modules/@angular/compiler-cli/src/ngtools_impl.js:53:22)
at Function.NgTools_InternalApi_NG_2.listLazyRoutes (.../node_modules/@angular/compiler-cli/src/ngtools_api.js:91:39)
at AotPlugin._getLazyRoutesFromNgtools (.../node_modules/@angular/cli/node_modules/@ngtools/webpack/src/plugin.js:241:66)
at _donePromise.Promise.resolve.then.then.then.then.then (.../node_modules/@angular/cli/node_modules/@ngtools/webpack/src/plugin.js:495:24)
at process._tickCallback (internal/process/next_tick.js:109:7)
```

1 个答案:

答案 0 :(得分:0)

我能够通过以下方式解决这个问题:

  • 全局更新至node@8.8.1以匹配与Meteor 1.6捆绑的版本
  • 更新到Meteor 1.6
  • 将符号链接添加到根package.json& Meteor目录中的package-lock.json
  • 删除node_modules文件夹并在根npm install上执行package.json
  • 避免对meteor npm install的任何调用(我在postinstall npm脚本中一直在进行调用以构建bcrypt二进制文件)