LWC エラーの対処方法2

+ [LWC エラーの対処方法に戻る](https://qiita.com/Keiji_otsubo/items/480135e98f6b0144ee63)
+ [LWC エラーの対処方法3](https://qiita.com/Keiji_otsubo/items/5e4bd0a547cf7548ad1f)


# Salesforce CLI is not installed

+ [Salesforce CLI is not installed](https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000PfB53)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328136/f7f40ecf-f066-869a-274f-bd897790a309.png)

:::note
**Set Salesforce CLI Path (Windows)**
See Installing the Salesforce CLI. After installing Salesforce CLI, if you get the error ‘Salesforce CLI is not installed’, most likely Salesforce CLI is not added as a path variable. To verify or add Salesforce CLI to your Windows path variable:

https://developer.salesforce.com/tools/vscode/en/troubleshooting


「Salesforce CLI のインストール」を参照してください。 Salesforce CLI をインストールした後、「Salesforce CLI がインストールされていません」というエラーが表示された場合は、Salesforce CLI がパス変数として追加されていない可能性があります。 Salesforce CLI を確認または Windows パス変数に追加するには、次の手順を実行します
:::

+ [When connect visual studio code with my new org show me the follow message after of acept auth and allow the access](https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000PeM4L)
+ [Trying to authorize an org in VSCode for Create a Hello World Lightning Web Component](https://trailhead.salesforce.com/ja/trailblazer-community/feed/0D54S00000PewRXSAZ)

+ [404 error installing CLI on the step "Get Ready to Develop"](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007Eag61SAB)

:::note
Try this: https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_install_cli.htm
:::

# Warning

```
Warning: The "force auth web login" command has been deprecated. Use "org login web" instead.
Warning: The "--setalias" flag has been deprecated. Use "--alias | -a" instead.
Warning: The "--instanceurl" flag has been deprecated. Use "--instance-url | -r" instead.
Warning: The "--setdefaultusername" flag has been deprecated. Use "--set-default | -s" instead.
Error (1): Invalid client credentials. Verify the OAuth client secret and ID. Error authenticating with auth code due to: request to https://login.salesforce.com//services/oauth2/token failed, reason: self signed certificate in certificate chain
```

:::note
Please check this article.

https://developer.salesforce.com/forums/?id=9062I000000DKBwQAO

 believe that was a  problem connection.  already is connected good.  
:::

# You have not authorized your Trailhead playground org via Salesforce Extensions or Salesforce Command line (CLI). Please install the development tools specified in this step and connect to the Trailhead Playground.

+ [Im getting this error when completing the challange, i followed the steps as mentioned in the url listed below](https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000R9J27)

:::note
I had this same issue and this "15 minute step" took me like 6-8 hours of troubleshooting over two days, which I finally just finished... The solution I found after uninstalling and reinstalling extensions, sfdx update multiple times, checked PATH multiple times, and every other thing I found on the web that didn't work was so simple yet not listed anywhere in the instructions and it wasn't a VS Code issue (for me at least).

Down at the bottom of the page for the task in trailhead right by the button for +100 points is your playground listing. Hit the dots next to it to pull up more menu options and there is one for linking. I can't get a screenshot since it's now complete and I don't want to start over, but if you click it you will have to login to salesforce and like two popups will ask you to verify stuff. Verify and it will take you back to trailhead where you will hit the +100 points button again and it should pass this time.

I'm not sure if there is an oversight in their instructions or if this was covered in one of the linked articles, but it gave me such a hard time for something so simple. I definitely feel like the trailhead instructions could be a little more clear. Hope this helps others avoid the headaches and downtime I took... Now maybe I can actually learn this platform :)

https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000JgRNM

私も同じ問題を抱えていて、この「15 分のステップ」では 2 日間にわたってトラブルシューティングに 6 ～ 8 時間かかりましたが、ようやく完了しました...拡張機能をアンインストールして再インストールし、sfdx を複数回更新し、PATH を確認した後に見つけた解決策何度も繰り返しましたが、Web 上で見つけた動作しなかったものはどれも非常に単純でしたが、説明書のどこにも記載されておらず、(少なくとも私にとっては) VS Code の問題ではありませんでした。

Trailhead のタスクのページの下部、+100 ポイントのボタンのすぐ下に、プレイグラウンドのリストがあります。その横にあるドットを押してさらにメニュー オプションを表示すると、リンク用のオプションが表示されます。完了したので最初からやり直すつもりはないのでスクリーンショットは取れませんが、クリックすると Salesforce にログインする必要があり、確認を求める 2 つのポップアップのようなメッセージが表示されます。確認すると、登山口に戻り、そこで +100 ポイント ボタンを再度押すと、今度は通過するはずです。

彼らの指示に見落としがあるのか​​、それともリンク先の記事でこれが取り上げられているのかはわかりませんが、これほど単純なことで私は非常に苦労しました。登山口の説明がもう少しわかりやすくてもいいのにと思います。これが他の人が私が経験した頭痛やダウンタイムを回避するのに役立つことを願っています...これで、私は実際にこのプラットフォームを学ぶことができるかもしれません:)
:::



# We can't find a Lightning Web Component named 'selector'.

+ [I have de following error We can't find a Lightning Web Component named 'selector'.](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V000074WFmG)

:::note
Follow the steps:

Lightning Web Component is not enabled in your org

To check if the Lightning Web Component is enabled, go to Setup > Lightning App Builder > Components and search the component as selector.

Lightning Web Component is installed in a different org or not published or not compatible salesforce version.

Finally, check selector.js file in the Handle Events in Lightning Web Components remove it and going on the order from trailhead. otherwise, reinstall it.

手順に従ってください：

Lightning Web コンポーネントが組織で有効になっていません

Lightning Web コンポーネントが有効かどうかを確認するには、[設定] > [Lightning アプリケーションビルダー] > [コンポーネント] に移動し、セレクタとしてコンポーネントを検索します。

Lightning Web コンポーネントが別の組織にインストールされているか、公開されていない、または互換性のない Salesforce バージョンにインストールされています。

最後に、Lightning Web コンポーネントのイベントの処理で selector.js ファイルを確認して削除し、Trailhead からの指示に従います。それ以外の場合は、再インストールしてください。
:::


# ContactController.cls * Illegal conversion from List<Contact> to List<Account> (4:9)

+ [Use Apex To Work With Data Challenge Visual Studio](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V000076Aon7)

:::note
I think that I figured this out. The ContactController.cls-meta.xml was interfering with the class somehow. When I deleted this, it ended up being ok. 

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328136/89537f28-df53-7d7e-6e00-3af89d6764d0.png)

これで分かったと思います。 ContactController.cls-meta.xml が何らかの理由でクラスに干渉していました。これを削除したら、無事に直りました。
:::

# No source backed components present in the package

+ [Get Ready To Troubleshoot: Deploy Source To Org Failed](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V000076CYDa)

:::note
 I figured it out. I accidentally saved the github directory on my desktop, and created the new project in my default directory. Therefore, there wasn't anything that I was able to push to my org. 

私はそれを考え出した。誤って github ディレクトリをデスクトップに保存し、デフォルトのディレクトリに新しいプロジェクトを作成してしまいました。したがって、組織にプッシュできるものは何もありませんでした。
:::

# We can’t find 'reduceErrors' imported into contactList.js#

+ [TrailHead not working correctly (Handle Server Errors)](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V000076Bw2T)

:::note
 I had to write the import as followed: 

import {reduceErrors} from './c/ldsUtils'
:::

# SalesforceSDKCore. RestClientError error0.

+ [Viewing object offline returns: (SalesforceSDKCore. RestClientError error0.)`](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V000078QkBm)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328136/a0acee2d-02c3-35a8-5066-1c772c46f888.png)

:::note
I pushed all metadata items from my Mobile Offline Starter kit and it resolved the issue. There may have been a missing file(s) and/or a clear cache solved my issue. 
:::

# destination path already exists and is not an empty directory

+ [To work locally on a repository, you first need to create a clone on your machine. To clone a repository, follow these steps: In GitHub, click the Code tab of the repository you just created. Click the Code button. Copy the clone URL to your clipboard. O](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V000078QM2U)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328136/6ce0b1a5-d51e-3f4a-629e-903246b5d887.png)

:::note
Please check this article.

https://stackoverflow.com/questions/50361138/destination-path-already-exists-and-is-not-an-empty-directory
:::




# The file or directory that you tried to deploy or retrieve isn't in a package directory that's specified in your sfdx-project.json file. Add this location to your "packageDirectories" value, or deploy or retrieve a different file or directory

+ [Cannot deploy source to org](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007FzNZN)


:::note
I was getting the same error on retrieving the components from org. So i went to the actual package.xml file on my vs code ide and right click > SFDX:Retreive Source in Manifest from org and it worked. Then you can try the SFDX: Deploy this source to Org

https://developer.salesforce.com/forums/?id=9062I000000IFKyQAO

組織からコンポーネントを取得するときに同じエラーが発生しました。そこで、vsコードIDEで実際のpackage.xmlファイルに移動し、右クリック> SFDX:Retreive Source in Manifest from orgをクリックすると機能しました。次に、SFDX を試すことができます: このソースを組織にデプロイします
:::

# 違う組織に接続していた

+ [I am also getting the error in VS Code with states that the proper permissions are not set to use Einstein for Developers extension.](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007IcWYJ)


# No MODULE named markup://c:list found : [markup://c:selector]

+ [Downloaded the Bike Selector app code and getting below error when deploying it Org. How to fix the error?](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007KX0Hf)

:::note
Update <isExposed>true</isExposed> and issue is resolved

https://developer.salesforce.com/forums/?id=9062I000000DNeDQAW
:::

# We can’t find ‘Count_Updated.messageChannel-meta.xml’.

+ [Cannot find Lightning component bundle Event Comms](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007JksCJ)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328136/c3518349-b857-4bf0-5a9c-cc58637c0e7a.png)

:::note
I resolved it by using a Windows OS VScode to deploy the message channel folder. I guess the issue is with the MacOS edition of VScode.

Windows OS VScode を使用してメッセージ チャネル フォルダーを展開することで解決しました。問題は VScode の MacOS 版にあると思います。
:::






# No such file or directory

+ [VS Code just stopped working - No such file or directory](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007H9Eqy)

:::note alert
sfdx force:auth:web:login --setalias vscodeOrg --instanceurl https://test.salesforce.com --setdefaultusername

/Users/[myUserName]/.local/share/sfdx/client/bin/sfdx: line 16: /Users/[myUserName]/.local/share/sfdx/client/bin/../7.209.6-8ba3197/bin/sfdx: No such file or directory

15:46:10.754 sfdx force:auth:web:login --setalias vscodeOrg --instanceurl https://test.salesforce.com --setdefaultusername

 ended with exit code 1
:::

:::note
Please check this article.

https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000Br4bl
:::




 # Too many callouts: 101"

 + [sf_devops:Too many callouts: 101 (when promoting an approved work item)](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007HLjJySAL)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328136/a5257928-2671-ccbb-4cee-c6a6124b1d28.png)


:::note
Encountered it for the first time today and was able to find the right info on my machine in .git > refs> remotes > origin > 'branch' .

今日初めてこれに遭遇し、 .git > refs > Remotes > Origin > 'branch' でマシン上の正しい情報を見つけることができました。
:::


# The `Execute Anonymous Apex` 

+ [Click Code Lens Execute Anonymous Apex highlighted in pink in the below screenshot?](https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000PfEgQ)

:::note
CRTL+" >  Execute Anonymous Apex > ENTER
:::




# "message": "error parsing or finding aura config: window.Aura not found" and in console  --> app:9608     POST http://localhost:3333/webruntime/api/apex/execute 500 (Internal Server Error)

+ [Hi people, I'm facing an issue in my LWC component while running it in a scratch org-local development server . (windows.aura not found)](https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000PfDgU)

:::note
Unfortunately, there is no longer a solution to the problem. We cannot disable the `Security Enhancements for CSRF Tokens for Lightning Apps` release update to eliminate CSRF token validation on the org backend side. We also don't have any workaround other than mock data to be retrieved. There is also no workaround for performing data creation/update operations. 

Deploying the metadata to the server and then saving the page in App Builder after each change doesn't look like a good development flow, similar to how we worked until 2020.

残念ながら、この問題に対する解決策はもうありません。 「Lightning アプリケーションの CSRF トークンのセキュリティ強化」リリース更新を無効にして、組織のバックエンド側での CSRF トークンの検証を排除することはできません。また、模擬データを取得する以外に回避策はありません。データの作成/更新操作を実行する場合の回避策もありません。

メタデータをサーバーにデプロイし、変更のたびに App Builder でページを保存するのは、2020 年までの作業方法と同様に、適切な開発フローとは思えません。
:::

# Entity of type 'EmailTemplate' named ' unfiled$public/my_email_template -o myOrg ' cannot be found.

+ [sf command to pull unfiled public email template](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007OqZon)

# Starting SFDX: Deploy Source to OrgINSUFFICIENT_ACCESS: use of the Metadata API requires a user with the ModifyAllData or ModifyMetadata permissions

+ [Unable to Deploy to Org on Visual studio](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007NAtY5)

:::note
To resolve this issue, do the following:

1. Login to Salesforce
2. Goto Setup > Manage Users > Users > Click on profile assigned to the User > Edit > Enable the ModifyAllData or ModifyMetadata permissions
3. Save
4. Republish Salesforce Connection. 

https://knowledge.informatica.com/s/article/563897?language=en_US
:::

:::note
It seems that you are likely authenticated as a non-administrator user.
Please try running "SFDX:Authorize an Org" from the command palette again.
This time, make sure to log in as a user with a system administrator profile.

おそらく管理者以外のユーザーとして認証されているようです。
コマンドパレットから「SFDX:Authorize an Org」を再度実行してください。
今回は、必ずシステム管理者プロファイルを持つユーザーとしてログインしてください。
:::


# FSL through package.xml from the Work Order object but the layout cannot be found.

+ [Cannot find layout](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007Ph8RuSAJ)

特定のオブジェクトのページ レイアウトを package.xml に追加するにはどうすればよいですか?
https://salesforce.stackexchange.com/questions/241475/how-to-add-any-specific-objects-page-layout-in-package-xml


# We could not find Apex class named 'AccountController'.

:::note alert
Warning: Ignoring extra certs from `null`, load failed: error:80000002:system library::No such file or directory
:::

+ [Completed the Use Visual Studio Code for Salesforce Development challenge, but cannot verify](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007US3mC)

:::note

VSCode で複数の組織が接続または承認されている場合、コードはデフォルトの組織セットの 1 つにデプロイされる必要があります。

If you have multiple orgs connected or authorized in VSCode, then your code must be getting dpeloyed to one of the default org set.

Try setting the org you want to use as default using below command:

sfdx force:config:set defaultusername = 'Username that you want to use'

And then confirm the list of orgs by using below command:

https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000A8uZISAZ

I'm also concerned about SSL warning.
https://stackoverflow.com/questions/70365875/error-during-creation-self-signed-ssl-with-openssl
:::


# self-signed certificate in certificate chain

+ [Error connecting SF with VSCode](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007T3CGD)

:::note alert
Error authenticating with auth code due to: request to https://login.salesforce.com//services/oauth2/token failed, reason: self-signed certificate in certificate chain

This is most likely not an error with the Salesforce CLI. Please ensure all information is accurate and try again.
:::

:::note
After installing node.js it started working for me. Not sure what was the issue. 

Even it's working on company's VPN

node.js をインストールした後、機能し始めました。何が問題だったのかわかりません。

会社のVPNでも動作しています
:::


# This class name's value is invalid: AccountServiceTest. Provide the name of an Apex class that has test methods.

+ [Error nessage in VS when try to complete Set Up Apex Replay Debugger](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007XI8TF)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328136/a53aa14f-741e-8309-597b-49c6568424cc.png)

:::note
After creating a new Playground, I put the same code in VS and Deployed it to the Org. All was fine this time and I could complete the challenge
:::


# Error running command sfdx.force.source.retrieve.component: this.node.children is not iterable. This is likely caused by the extension that contributes sfdx.force.source.retrieve.component.

+ [Error running command sfdx.force.source.retrieve.component: this.node.children is not iterable. This is likely caused by the extension that contributes sfdx.force.source.retrieve.component.](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007X8lDQSAZ)

:::note
SFDX commands are depreciated, i suggest you should update the Salesforce Cli or if not updated in long time uninstall old version & install the new one.

SFDX コマンドは廃止されました。Salesforce Cli を更新するか、長期間更新されない場合は古いバージョンをアンインストールして新しいバージョンをインストールすることをお勧めします。
:::


# We can’t query your org. Make sure that you’re connected to this org and have permissions to view the object and fields.

+ [Facing error while authenticating sandbox org in Visual Studio Code](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007X9TwD)

:::note
Just follow the below link steps

https://www.apexhours.com/how-to-setup-visual-studio-code-for-salesforce/

also, update your CLI, Write this line in your command prompt sfdx update and press enter.

 https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_update_cli.htm

https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000HlyxXSAR
:::

# structuredClone is not defined

+ ["Create a Hello World Lightning Web Component" deploy error.](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007ZAtiq)

:::note
Probably, you can solve the issue by trying a lower version of the Salesforce CLI Integration(vscode Extension), that might help.

I was able to confirm the operation in the following environment.

CLI Version : 2.25.7
Node.js : 20:11:0
Salesforce CLI Integration : v59.9.0

https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007X8N5ySAF
:::

# StructureClone not defined

+ [Getting StructureClone not defined](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007XIO9A)

:::note
Update your VS code and Salesforce CLI with latest version and then try.
If it is latest one then uninstall  Salesforce CLI and reinstall.
Check the path is correct or not

I got the same issue now it is resolved 

S コードと Salesforce CLI を最新バージョンに更新してから試してください。
最新の場合は、Salesforce CLI をアンインストールして再インストールします。
パスが正しいかどうかを確認してください

同じ問題が発生しましたが、現在は解決されています
:::


# Installing plugin @ind-rcg/modeler-sfdx-cli-plugin@latest... failed

+ [I'm not able to install the @ind-rcg/modeler-sfdx-cli-plugin](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007ZBwIg)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328136/91916220-ea81-6e3c-04c0-34037e36401f.png)

:::note
I took the task of analyzing the error, fortunately I have solved it, I was missing some components that were not installed.

Now everything works as before with the plugin update.

https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007UtA2wSAF

私はエラーを分析する仕事を引き受けましたが、幸いにもそれは解決しました。インストールされていないコンポーネントがいくつかありませんでした。

プラグインの更新により、すべてが以前と同じように機能するようになりました。
:::