Angular 库 - 无法读取未定义的属性“ɵmod”

2023-12-09

我一直在使用@ngx/json-ld 包来自 Cory Rylan 在我的角度组件上渲染 LD+json。今天我尝试将我的 Angular 应用程序升级到 Angular 12,但现在出现错误。 所以我决定创建一个新项目包含此组件的角度库。同一存储库中的演示项目运行得很好。但是当我在项目中使用自己的库时,我也遇到了同样的错误。

Uncaught TypeError: Cannot read property 'ɵmod' of undefined

未捕获的类型错误:无法读取未定义的属性“ɵmod”

我该如何解决这个问题?这是角度本身的问题吗?

git clone https://github.com/PieterjanDeClippel/LdJsonTest
cd LdJsonTest
npm install
npm start -- --open

Edit:

然而,当我在 StackBlitz 中创建项目时,一切似乎都工作正常......


我不知道是谁发表的评论,但你是对的。安装的包应包含文件夹bundles, esm2015, fesm2015, lib。显然我是npm publishing 错误的文件夹。

All I needed to do was change my workflow to publish package = dist/path/to/package.json instead of projects/path/to/package.json.

我的最终工作流程是:

name: npm-publish

on:
  push:
    branches: [ master ]

jobs:
  build:
  
    name: npm-publish
    runs-on: ubuntu-latest
    
    permissions: 
      contents: read
      packages: write 
    
    steps:
    - name: Checkout
      uses: actions/checkout@v2
    
    - name: Setup node
      uses: actions/setup-node@v2
      with:
        node-version: 14

    - name: Install dependencies
      run: npm install
    
    - name: Build
      run: npm run build -- --prod

    - name: Test
      run: npm run test-headless
    
    - name: Push to NPM
      uses: JS-DevTools/npm-publish@v1
      with:
        package: 'dist/path/to/package.json'
        registry: 'https://registry.npmjs.org'
        token: ${{ secrets.PUBLISH_NODE_TO_NPMJS_COM }}
        access: 'public'

    - name: Push to Github
      uses: JS-DevTools/npm-publish@v1
      with:
        package: 'dist/path/to/package.json'
        registry: 'https://npm.pkg.github.com'
        token: ${{ github.token }}
        access: 'public'

哪里的root package.json包含以下脚本(其他都不重要):

{
  ...,
  "scripts": {
    ...
    "test-headless": "ng test --watch=false --browsers=ChromeHeadless"
  }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Angular 库 - 无法读取未定义的属性“ɵmod” 的相关文章

随机推荐