Warning in vtex link: "Blocks were defined twice, this could cause unexpected behavior"

vtex link gives me many warnings:

warn: Blocks 'form-input.text#firstName,form-input.text#lastName,form-input.text#email,form-input.text#phone' were defined twice, this could cause unexpected behavior.

But I don’t see these defined more than once in the code.

Hi @ymelman, could you share more information on the code that generates this warning?

It might be the case that blocks with the same name are defined in other blocks files, the scope is not limited to each source file.

What would you do about finding the duplications? I did findstr ... *.* and did not get any duplicated definitions.

Use something than can search in all files, and search for all the pointed duplicates.

Any suggestion of a tool? The top directory is:

04/29/2021  08:49 AM    <DIR>          .
04/29/2021  08:49 AM    <DIR>          ..
04/29/2021  08:49 AM               304 .all-contributorsrc
04/29/2021  08:49 AM               218 .editorconfig
04/29/2021  08:49 AM                35 .eslintignore
04/29/2021  08:49 AM                44 .eslintrc
04/29/2021  08:49 AM    <DIR>          .github
04/29/2021  08:49 AM               498 .gitignore
04/29/2021  08:49 AM                23 .prettierrc
04/29/2021  08:49 AM    <DIR>          .vscode
04/29/2021  08:49 AM               142 .vtexignore
04/29/2021  08:49 AM    <DIR>          assets
04/29/2021  08:49 AM             5,163 CHANGELOG.md
04/29/2021  08:49 AM                89 crowdin.yml
04/29/2021  08:49 AM    <DIR>          docs
04/29/2021  08:50 AM             2,652 manifest.json
04/29/2021  08:49 AM    <DIR>          messages
04/29/2021  08:49 AM             8,162 package-lock.json
04/29/2021  08:49 AM             1,026 package.json
04/29/2021  08:50 AM    <DIR>          react
04/29/2021  08:49 AM    <DIR>          sitemap
04/29/2021  08:49 AM    <DIR>          store
04/29/2021  08:49 AM    <DIR>          styles
04/29/2021  08:49 AM            95,843 yarn.lock
              13 File(s)        114,199 bytes
              11 Dir(s)  924,386,271,232 bytes free
findstr /s  "string" *.* searches all files```

Here are the warnings I get:

15:37:05.873 - info: Running yarn in react
yarn install v1.22.10
warning package.json: No license field
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
warning CHANGE_ME@0.0.0: No license field
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.37s.
15:37:06.571 - info: Finished running yarn
15:37:06.572 - info: Linking app n95.projectn95@4.0.1
15:37:06.660 - info: Sending 106 files
15:37:06.666 - info: Link ID: d8a7765403f7cf07
15:37:06.671 - info: Project size: 1.04MB
15:37:06.671 - info: Compressing project files...
15:37:06.812 - info: Compressed project size: 0.39MB
15:37:07.294 - info: Sending files: 100% - 0.39MB/0.39MB
15:37:07.397 - info: Build accepted for n95.projectn95@4.0.1 at n95/yaelws1 vtex.builder-hub@0.278.0
15:37:07.513 - info: Starting build for app n95.projectn95@4.0.1 vtex.builder-hub@0.278.0
15:37:07.979 - error: Failed to get dependencies GraphQL vtex.builder-hub@0.278.0
15:37:08.190 - info: Duplicate entry for vtex.flex-layout.css. Please, mind CSS rule overriding. vtex.builder-hub@0.278.0
15:37:08.373 - warn:
CSS validation was skipped for the following apps because of their current major version:

- vtex.login@2.x
- vtex.my-account@1.x

 Don't rely on this behavior when updating to a newer major version. vtex.builder-hub@0.278.0
15:37:08.485 - warn: Blocks 'flex-layout.row#separator,rich-text#orgAddress,rich-text#reg-success-submit' were  defined twice, this could cause unexpected behavior. Please check your json files and remove duplicated block definitions. vtex.builder-hub@0.278.0
15:37:20.015 - warn: React builder could not extract messages used in the following locations: vtex.builder-hub@0.278.0 
15:37:20.024 - warn: React builder could not parse automatically all messages in your code. Thus, pages containing this app may run MUCH SLOWER than average.
You can fix this by declaring statically all messages in your code. If you need a dynamic message, please use the "defineMessages" function, also provided by react-intl.
Messages causing this conflict:
If this error continues after applying the aforementioned changes, please contact @io-devtools-team. vtex.builder-hub@0.278.0
15:37:21.483 - info: Bundle: 76 files - 0.46MB vtex.builder-hub@0.278.0
15:37:21.493 - info: Sent bundle to Apps in 1330ms vtex.builder-hub@0.278.0
15:37:21.502 - info: App linked successfully vtex.builder-hub@0.278.0
15:37:21.546 - info: Store live at: https://yaelws1--n95.myvtex.com vtex.builder-hub@0.278.0
15:37:21.600 - info: Assets build completed successfully vtex.builder-hub@0.278.0
15:37:21.610 - info: Sending locale change event vtex.builder-hub@0.278.0
15:37:21.619 - info: Sending reload event vtex.builder-hub@0.278.0
15:37:21.625 - info: You can try out the queries in this app using the GraphiQL IDE available at:
https://yaelws1--n95.myvtex.com/_v/private/n95.projectn95@4.0.1/graphiql/v1 vtex.builder-hub@0.278.0```

VS Code, open the entire folder and use ctrl+shift+f to search.

I found the problem. Still don’t understand why I got so many more previously but for now you can close this issue.

@ymelman would you mind sharing what the problem was? Your answer could help others in the future.

Keep in mind that the purpose of our community is not to provide support, but to accelerate knowledge sharing in our ecosystem :rocket:

When I ran vtex link today, I got that only 3 blocks are duplicated:

15:37:08.485 - warn: Blocks 'flex-layout.row#separator,rich-text#orgAddress,rich-text#reg-success-submit' were  defined twice, this could cause unexpected behavior. Please check your json files and remove duplicated block definitions. vtex.builder-hub@0.278.0

Searching for one of them with findstr I saw that reg-success-submit was defined twice:

C:\Users\ymelm\projectn95\shop.projectn95.org>findstr /s /c:"reg-success-submit" *.jsonc
store\blocks\checkout\order-placed.jsonc:      "rich-text#reg-success-submit"
store\blocks\checkout\order-placed.jsonc:  "rich-text#reg-success-submit": {
store\blocks\registration.jsonc:      "rich-text#reg-success-submit"
store\blocks\registration.jsonc:  "rich-text#reg-success-submit": {

To fix it, commented out one of them. I am curious why previously I got so many more, but it’s done!

1 Like

@georgebrindeiro - thank you very much for your responses. I appreciate these a lot.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.