【问题标题】:Module not found: Error: Can't resolve 'commonjs-proxy:找不到模块:错误:无法解析'commonjs-proxy:
【发布时间】:2018-06-15 09:51:37
【问题描述】:

我从头开始使用 angular -cli 创建了 angular(6) 项目。 如the official wiki中所述创建库

尝试导入我的新库时出错。 我一直在检查配置 2 天。

ERROR in ./node_modules/tvmazerrr/fesm5/tvmaze.js Module not found: Error: Can't resolve 'commonjs-proxy:./lib/tvmaze.component' in '/Users/alexanderkozhevin/Desktop/lib-demo/node_modules/tvmazerrr/fesm5' ERROR in ./node_modules/tvmazerrr/fesm5/tvmaze.js Module not found: Error: Can't resolve 'commonjs-proxy:./lib/tvmaze.module' in '/Users/alexanderkozhevin/Desktop/lib-demo/node_modules/tvmazerrr/fesm5' ERROR in ./node_modules/tvmazerrr/fesm5/tvmaze.js Module not found: Error: Can't resolve 'commonjs-proxy:./lib/tvmaze.service' in '/Users/alexanderkozhevin/Desktop/lib-demo/node_modules/tvmazerrr/fesm5' ERROR in ./node_modules/tvmazerrr/fesm5/tvmaze.js Module not found: Error: Can't resolve 'commonjs-proxy:./public_api' in '/Users/alexanderkozhevin/Desktop/lib-demo/node_modules/tvmazerrr/fesm5' ERROR in ./node_modules/tvmazerrr/fesm5/tvmaze.js Module not found: Error: Can't resolve 'commonjs-proxy:./tvmaze.component' in '/Users/alexanderkozhevin/Desktop/lib-demo/node_modules/tvmazerrr/fesm5' ERROR in ./node_modules/tvmazerrr/fesm5/tvmaze.js Module not found: Error: Can't resolve 'commonjs-proxy:@angular/core' in '/Users/alexanderkozhevin/Desktop/lib-demo/node_modules/tvmazerrr/fesm5' ERROR in ./node_modules/tvmazerrr/fesm5/tvmaze.js Module not found: Error: Can't resolve 'commonjsHelpers' in '/Users/alexanderkozhevin/Desktop/lib-demo/node_modules/tvmazerrr/fesm5'

【问题讨论】:

  • 也许你在你的库的 package.json 中忘记了 commonjs-proxy?
  • 不,这是包错误。 @Powkachu
  • @AlexanderKozhevin 请告诉我们您为解决包裹中的此错误所采取的步骤。

标签: angular angular-cli angular6


【解决方案1】:

我见过的一个解决方案是,在正在构建的库的 tsconfig.lib.json 中,模块应该设置如下:

"module": "es2015"

不设置此值或将其设置为更高的值可能会导致上述问题。 另请参阅此 git 条目:

https://github.com/ng-packagr/ng-packagr/issues/944

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-29
    • 1970-01-01
    • 2020-12-15
    • 2017-12-29
    • 2019-10-27
    • 2019-12-01
    • 2023-03-22
    相关资源
    最近更新 更多