@slon said in BAS ничего не выводит при запуске модуля Node.js с этим кодом:
@Ajshma этот код ведь должен работать, или в басе есть какое-то ограничение?
https://community.bablosoft.com/topic/4450/websocket-на-node-js/6
Скрипт использует node и модуль node-fetch. Скрипт работает на версии 24.1.1 и не работает на 24.2.2 и старше, выдает ошибку:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\Andrey\AppData\Roaming\BrowserAutomationStudio\apps\24.2.3\e\896c.H1qP\distr\node_modules\node-fetch\src\index.js
require() of ES modules is not supported.
require() of C:\Users\Andrey\AppData\Roaming\BrowserAutomationStudio\apps\24.2.3\e\896c.H1qP\distr\node_modules\node-fetch\src\index.js from C:\Users\Andrey\AppData\Roaming\BrowserAutomationStudio\apps\24.2.3\e\896c.H1qP\distr\lib\custom\3slzmjnyo5z.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Users\Andrey\AppData\Roaming\BrowserAutomationStudio\apps\24.2.3\e\896c.H1qP\distr\node_modules\node-fetch\package.json.
Файл с примером
fortest.zip
@Andrey-0 said in BAS выдает ошибку на версии старше 24.2.2 с node и node module:
Скрипт использует node и модуль node-fetch. Скрипт работает на версии 24.1.1 и не работает на 24.2.2 и старше, выдает ошибку:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\Andrey\AppData\Roaming\BrowserAutomationStudio\apps\24.2.3\e\896c.H1qP\distr\node_modules\node-fetch\src\index.js require() of ES modules is not supported. require() of C:\Users\Andrey\AppData\Roaming\BrowserAutomationStudio\apps\24.2.3\e\896c.H1qP\distr\node_modules\node-fetch\src\index.js from C:\Users\Andrey\AppData\Roaming\BrowserAutomationStudio\apps\24.2.3\e\896c.H1qP\distr\lib\custom\3slzmjnyo5z.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Users\Andrey\AppData\Roaming\BrowserAutomationStudio\apps\24.2.3\e\896c.H1qP\distr\node_modules\node-fetch\package.json.Файл с примером
fortest.zip
У меня эту ошибку выдаёт и на 24.1.1 версии

и даже на 23.2.2

@Andrey-0, https://www.npmjs.com/package/node-fetch#installation, рабочий вариант: const {default: fetch} = await import('node-fetch'); или использовать fetch ниже 3 версии
Пример: fortest.xml