Skip to content

[dev-tool] error executing samples for ESM packages #29672

@jeremymeng

Description

@jeremymeng

https://dev.azure.com/azure-sdk/internal/_build/results?buildId=3778146&view=logs&j=4eaf6b84-07d0-5e66-f484-4e9defa3fc2f&t=c0bbcefe-75de-57d8-29b4-466c419539c4 (MS INTERNAL)

Invoking "rushx execute:samples"

Found configuration in D:\a_work\1\s\rush.json

Rush Multi-Project Build Tool 5.120.6 - Node.js 18.20.2 (LTS)
"dev-tool samples run samples-dev"

[run-samples] Running D:\a_work\1\s\sdk\template\template\samples-dev\getConfigurationSetting.ts
[run-samples] Error in D:\a_work\1\s\sdk\template\template\samples-dev\getConfigurationSetting.ts:
[run-samples] Error: Must use import to load ES Module: D:\a_work\1\s\sdk\template\template\samples-dev\getConfigurationSetting.ts
require() of ES modules is not supported.
require() of D:\a_work\1\s\sdk\template\template\samples-dev\getConfigurationSetting.ts from D:\a_work\1\s\common\tools\dev-tool\src\commands\samples\run.ts is an ES module file as it is a .ts file whose nearest parent package.json contains "type": "module" which defines all .ts files in that package scope as ES modules.
Instead change the requiring code to use import(), or remove "type": "module" from D:\a_work\1\s\sdk\template\template\package.json.

[run-samples] Errors occurred in the following files:
[run-samples] - getConfigurationSetting.ts ( Error: Must use import to load ES Module: D:\a_work\1\s\sdk\template\template\samples-dev\getConfig )
[dev-tool] Errors occured. See the output above.
Error: Failed calling dev-tool samples run samples-dev. Exit code: 1
##[error]Cmd.exe exited with code '1'.
Finishing: Execute Samples

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.EngSysThis issue is impacting the engineering system.dev-toolIssues related to the Azure SDK for JS dev-tool

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions