rollup version is too old
huhuang03 opened this issue · comments
Aha commented
If I use lates rollup 3.17.2
(now is 1.29.0
), then I run yarn run dev
, the error throws:
rollup-starter-lib [master] % yarn run build
yarn run v1.22.19
$ rollup -c
(node:70006) 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)
[!] RollupError: Node tried to load your configuration file as CommonJS even though it is likely an ES module. To resolve this, change the extension of your configuration to ".mjs", set "type": "module" in your package.json file or pass the "--bundleConfigAsCjs" flag.
Original error: Cannot use import statement outside a module
https://rollupjs.org/command-line-interface/#bundleconfigascjs
/Users/hwf/source/rollup-starter-lib/rollup.config.js:3
import pkg from './package.json';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1001:16)
at Module._compile (internal/modules/cjs/loader.js:1049:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at ModuleWrap.<anonymous> (internal/modules/esm/translators.js:203:29)
at ModuleJob.run (internal/modules/esm/module_job.js:183:25)
at async Loader.import (internal/modules/esm/loader.js:178:24)
at async getConfigFileExport (/Users/hwf/source/rollup-starter-lib/node_modules/rollup/dist/shared/loadConfigFile.js:432:17)
at async Object.loadConfigFile (/Users/hwf/source/rollup-starter-lib/node_modules/rollup/dist/shared/loadConfigFile.js:391:59)
Seems like need do this if want use rollup3.x: