#values;
// …
toString() {
return this.#values.join(", ");
}
}
А потом я импортирую этот класс из app.js :
import { Color } from "./color.mjs";
< /code>
Вот ошибка: < /p>
Uncaught SyntaxError SyntaxError: Illegal return statement
at compileSourceTextModule (/internal/modules/esm/utils:338:16)
at moduleStrategy (/internal/modules/esm/translators:102:18)
at #translate (/internal/modules/esm/loader:468:12)
at loadAndTranslate (/internal/modules/esm/loader:515:27)
--- await ---
at runEntryPointWithESMLoader (/internal/modules/run_main:138:19)
at loadESMFromCJS (/internal/modules/cjs/loader
at (/internal/modules/cjs/loader
at (/internal/modules/cjs/loader
at (/internal/modules/cjs/loader
at (/internal/modules/cjs/loader
at traceSync (/diagnostics_channel:322:14)
at wrapModuleLoad (/internal/modules/cjs/loader:220:24)
at executeUserEntryPoint (/internal/modules/run_main:170:5)
at (/internal/main/run_main_module:36:49)
utils:338
No debugger available, can not send 'variables'
Почему я не могу импортировать класс в app.js ? Чего не хватает в моем коде? И как исправить?vscode\launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"/**"
],
"program": "${workspaceFolder}\\app.js"
}
]
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... om-node-js
Мобильная версия