You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From what I can gather, the Node engine in this package copies the input script file to a temp directory and then passes that file to Node to be rendered.
However, if the script uses ES modules (ES6 import instead of CommonJS require) and the accompanying package.json isn't also copied (with the type attribute being set to "module"), Node gives an "SyntaxError: Cannot use import statement outside a module" error. Without a package.json that has a type attribute set to "module", Node treats the script as CommonJS by default.
A potential solution could be copying the package.json file along with the script file to the temp directory, or piping the script into Node with the --input-type=module flag.
The lack of support for ES modules would be an issue for someone new to front-end JS frameworks who's following the Vue SSR basic tutorial which requires ES modules in the example.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
From what I can gather, the Node engine in this package copies the input script file to a temp directory and then passes that file to Node to be rendered.
However, if the script uses ES modules (ES6
import
instead of CommonJSrequire
) and the accompanyingpackage.json
isn't also copied (with thetype
attribute being set to"module"
), Node gives an "SyntaxError: Cannot use import statement outside a module" error. Without apackage.json
that has atype
attribute set to"module"
, Node treats the script as CommonJS by default.A potential solution could be copying the
package.json
file along with the script file to the temp directory, or piping the script into Node with the--input-type=module
flag.The lack of support for ES modules would be an issue for someone new to front-end JS frameworks who's following the Vue SSR basic tutorial which requires ES modules in the example.
Beta Was this translation helpful? Give feedback.
All reactions