【问题标题】:Share `node_modules` between Meteor 1.6 server & Angular CLI client Angular-Meteor subprojects?在 Meteor 1.6 服务器和 Angular CLI 客户端 Angular-Meteor 子项目之间共享“node_modules”?
【发布时间】:2018-04-16 03:20:42
【问题描述】:

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

但是,从出现在服务器目录根目录中的新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)
```

【问题讨论】:

  • 错误信息格式化

标签: meteor angular-cli angular-meteor


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2015-08-07
    • 2016-05-03
    • 2017-05-24
    • 1970-01-01
    • 2014-06-09
    • 1970-01-01
    • 1970-01-01
    • 2016-02-24
    • 2021-10-23
    相关资源
    最近更新 更多