TransWikia.com

Push fail for "force:source:push

Salesforce Asked by Noor A Shuvo on October 4, 2021

I am creating an lwc. Below is the js code

import { LightningElement, track } from "lwc";
export default class HelloIteration extends LightningElement {
  @track
  contacts = [
    {
      Id: 1,
      Name: "Amy Taylor",
      Title: "VP of Engineering"
    },
    {
      Id: 2,
      Name: "Michael Jones",
      Title: "VP of Sales"
    },
    {
      Id: 3,
      Name: "Jennifer Wu",
      Title: "CEO"
    }
  ];
}

And HTML is

<lightning-card title="ContactInformation" icon-name="custom:custom14">
  <div class="slds-m-around_medium">
    <template for:each={contacts} for:item="contact">
      <div key={contact.Id}>
        {contact.Name}, {contact.Title}
      </div>
    </template>
  </div>
</lightning-card>

When I am trying to push it, an error occurred

Error  force-appmaindefaultlwcmyFirstWebComponentmyFirstWebComponent.js  bad result: TypeError: Cannot read property 'parent' of undefined 
   at prune (/home/sfdc/tools/lwc/1.3.7-226.6/node_modules/@lwc-platform/sfdc-lwc-compiler/node_modules/@lwc-platform/sfdc-lwc-metadata/dist/template/transform/binding.js:111:17)    at getPrunedPath (/home/sfdc/tools/lwc/1.3.7-226.6/node_modules/@lwc-platform/sfdc-lwc-compiler/node_modules/@lwc-platform/sfdc-lwc-metadata/dist/template/transform/binding.js:121:12)    at elements.forEach.component (/home/sfdc/tools/lwc/1.3.7-226.6y.forEach (<anonymous>)    at Object.transform (/home/sfdc/tools/lwc/1.3.7-226.6/node_modules/@lwc-platform/
ERROR running force:source:push:  Push failed.

The linter is throwing the below error

enter image description here

How to solve the issue?

One Answer

The HTML for the component needs to be wrapped in a <template> tag. Change the HTML to the following and try re-pushing:

<template>
  <lightning-card title="ContactInformation" icon-name="custom:custom14">
    <div class="slds-m-around_medium">
      <template for:each={contacts} for:item="contact">
        <div key={contact.Id}>
          {contact.Name}, {contact.Title}
        </div>
      </template>
    </div>
  </lightning-card>
</template>

Correct answer by TrevorBliss on October 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP