在 Meteor 1.6 服务器和 Angular CLI 客户端 Angular-Meteor 子项目之间共享`node_modules`?
Share `node_modules` between Meteor 1.6 server & Angular CLI client Angular-Meteor subprojects?
我一直在使用 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)
```
我通过以下方式解决了这个问题:
- 全局更新到
node@8.8.1
以匹配与 Meteor 1.6 捆绑的版本
- 正在更新到 Meteor 1.6
- 将符号链接添加到 Meteor 目录中的根目录
package.json
& package-lock.json
- 删除
node_modules
文件夹并对根 package.json
执行 npm install
- 避免对
meteor npm install
的任何调用(我一直在 postinstall
npm 脚本中执行此操作以构建 bcrypt 二进制文件)
我一直在使用 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)
```
我通过以下方式解决了这个问题:
- 全局更新到
node@8.8.1
以匹配与 Meteor 1.6 捆绑的版本 - 正在更新到 Meteor 1.6
- 将符号链接添加到 Meteor 目录中的根目录
package.json
&package-lock.json
- 删除
node_modules
文件夹并对根package.json
执行 - 避免对
meteor npm install
的任何调用(我一直在postinstall
npm 脚本中执行此操作以构建 bcrypt 二进制文件)
npm install