找不到模块:错误:无法解析"commonjs-proxy:



我从头开始用angular -cli创建了angular(6(项目。 按照官方维基中的说法创建了库

尝试导入我的新库时出现错误。 我已经检查配置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'

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

"module": "es2015"

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

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

最新更新