Answer the question
In order to leave comments, you need to log in
What is node.js referring to when showing a server startup error?
I can't find on the internet what's wrong with the experimental import function. 100% error text will not be enough, so I expect questions about what else to show from the configs.
"C:\Program Files\nodejs\node.exe" --experimental-json-modules C:\git\fast-start-react\src\appExpress.js
Console output is saving to: C:\git\fast-start-react\logs\server-node-log.log
(node:12276) ExperimentalWarning: The ESM module loader is experimental.
internal/modules/esm/module_job.js:111
const namedImports = StringPrototypeMatch(importStatement, /{.*}/)[0];
^
TypeError: Cannot read property '0' of null
at ModuleJob._instantiate (internal/modules/esm/module_job.js:111:77)
at async ModuleJob.run (internal/modules/esm/module_job.js:136:20)
at async Loader.import (internal/modules/esm/loader.js:179:24)
Process finished with exit code 1
Answer the question
In order to leave comments, you need to log in
TypeError: Cannot read property '0' of null
in this case, it says that it cannot read the '0' property of null
, that is,
StringPrototypeMatch(importStatement, /{.*}/)
instead of an array (or possibly instead of an object or even a string), it gives you null
in the simplest case, you need to add a check for the presence of the desired data type. like this
const match = StringPrototypeMatch(importStatement, /{.*}/);
if( !match ) {
return; // сопоставлений не найдено, дальшейшие действия не имеют смысла
}
const namedImports = match[0];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question