Я использую синтаксис модуля ES6 на моем nodejs сервере:
пакет. json
"type": "module"
Я (успешно) запускаю свой сервер как локальный nodejs процесс. Например:
"scripts": {
"dev": "npm outdated ; nodemon --experimental-modules --inspect=4001 main.local.js"
}
Проблема: если я запускаю свой сервер через sam local:
"scripts": {
"dev-sam": "sam local start-api --skip-pull-image",
}
Я получаю ошибку:
Warning: require() of ES modules is not supported.
require() of /var/task/main.js from /var/runtime/UserFunction.js is an ES module file
as it is a .js file whose nearest parent package.jsoncontains "type": "module" which
defines all .js files in that package scope as ES modules.
Instead rename main.js to end in .cjs, change the requiring code to use import(), or
remove "type": "module" from /var/task/package.json.
Мой вывод: я нужно указать время выполнения nodejs, чтобы включить экспериментальную поддержку модуля es6.
Вопрос: как мне это сделать?
Пробовал (не работает):
"scripts": {
"dev-sam": "sam local start-api --experimental-modules --skip-pull-image",
}