Share `node_modules` between Meteor 1.6 server & Angular CLI client Angular-Meteor subprojects?

喜夏-厌秋 提交于 2019-12-11 15:19:27

问题


I have been using Meteor 1.3.x-1.5.x for the server in an Angular-Meteor project with a web client built via Angular CLI. Up until Meteor 1.6, I have been able to use a single node_modules directory shared via a symlink to reduce the size of and easily keep in sync the many shared dependencies between the client and server, following the example of the Angular-Meteor starter applications.

However, from the new package-lock.json file appearing in the root of the server directory, Meteor 1.6 appears to install its own dependencies in node_modules, including many @angular/* dependencies, which result in me get the following errors due to the multiple, conflicting package installations. Any recommendations?

```
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:


I was able to resolve this by:

  • updating to node@8.8.1 globally to match the version bundled with Meteor 1.6
  • updating to Meteor 1.6
  • adding symlinks to the root package.json & package-lock.json inside the Meteor directory
  • deleting the node_modules folder and performing an npm install on the root package.json
  • avoiding any calls to meteor npm install (which I had been doing in a postinstall npm script to build the bcrypt binary)


来源:https://stackoverflow.com/questions/47094987/share-node-modules-between-meteor-1-6-server-angular-cli-client-angular-mete

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!