Поделиться `node_modules` между сервером Meteor 1.6 и клиентом Angular CLI подпроекты Angular-Meteor?

Я использую Meteor 1.3.x-1.5.x для сервера в проекте Angular-Meteor с веб-клиентом, созданным через Angular CLI. Вплоть до 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)
```

person Keith Gillette    schedule 03.11.2017    source источник
comment
сообщение об ошибке отформатировано   -  person Heri    schedule 04.11.2017


Ответы (1)


Я смог решить это:

  • обновление до [email protected] глобально, чтобы соответствовать версии, связанной с Meteor 1.6
  • обновление до метеора 1.6
  • добавление символических ссылок в корень package.json и package-lock.json внутри каталога Meteor
  • удаление папки node_modules и выполнение npm install в корневом каталоге package.json
  • избегая любых вызовов meteor npm install (что я делал в сценарии postinstall npm для сборки двоичного файла bcrypt)
person Keith Gillette    schedule 16.11.2017