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
For the TypeScript package, the published package.json does not include a { "type": "module" } specification, which means that Node treats the package modules as CommonJS modules. However, the compiled output only contains ECMAScript modules (e.g. export statements).
This means that the package cannot be imported using vanilla Node.js, because it treats the package/modules as CommonJS modules. There isn't really a way to override this behaviour as a library user.
This results in syntax errors, for example:
(node:11542) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/my-project/node_modules/@material/material-color-utilities/dist/index.js:17
export * from './blend/blend';
^^^^^^
SyntaxError: Unexpected token 'export'
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1027:15)
at Module._compile (node:internal/modules/cjs/loader:1063:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29)
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
Node.js v17.8.0
This should be resolvable by either publishing CommonJS modules, or by making it explicit that this package uses ECMAScript modules. The latter can be achieved by adding {"type": "module"} to package.json or by using .mjs extensions. In addition, all compiled imports should explicitly specify the file extension (see #35).
For the TypeScript package, the published package.json does not include a
{ "type": "module" }
specification, which means that Node treats the package modules as CommonJS modules. However, the compiled output only contains ECMAScript modules (e.g.export
statements).This means that the package cannot be imported using vanilla Node.js, because it treats the package/modules as CommonJS modules. There isn't really a way to override this behaviour as a library user.
This results in syntax errors, for example:
This should be resolvable by either publishing CommonJS modules, or by making it explicit that this package uses ECMAScript modules. The latter can be achieved by adding
{"type": "module"}
topackage.json
or by using.mjs
extensions. In addition, all compiled imports should explicitly specify the file extension (see #35).See also:
The text was updated successfully, but these errors were encountered: