12
  1. i want to install rollup-plugin-visualizer but its need to update rollup.

  2. updated rollup from 1.8.0 to 3.1.0

    got error

    [!] 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.
    
  3. delete node-modules folder and package-lock.json and install again npm i

got error

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: @bet-core/ui@2.4.0
npm ERR! Found: rollup@3.1.0
npm ERR! node_modules/rollup
npm ERR!   dev rollup@"^3.1.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer rollup@">=0.60.0 <3" from rollup-plugin-babel@4.4.0
npm ERR! node_modules/rollup-plugin-babel
npm ERR!   dev rollup-plugin-babel@"^4.3.2" from the root project

rollup-plugin-babel npm page says !!!

This package has been deprecated and is no longer maintained. Please use @rollup/plugin-babel.
  1. i have delete rollup-plugin-babel then install @rollup/plugin-babel. now i got this error
[!] 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

can someone tell me where to look for this error solutions?

Garo Gabrielyan
  • 466
  • 2
  • 7
  • 20

4 Answers4

11

i have find the solution. At first changed format from 'esm' to 'cjs' in rollup.config.js

export default {
    ...
    output: [
             {
                format: 'cjs',
                ...
            },
       
    ]
};

then rollup.config.js changed to rollup.config.mjs

Garo Gabrielyan
  • 466
  • 2
  • 7
  • 20
5

Hi man I have the same issue running "npm run rollup"

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.

What I found:

Mati
  • 63
  • 6
2

If you're using node v14 upgrade it to v16, this works in my case, especially when you run Rollup in GitHub Action:

name: Release @vueup/vue-quill

on: 
  push: 
    branches: 
      - alpha
      - beta
      - master
    paths: 
      - 'packages/vue-quill/**'
jobs: 
  release: 
    name: Build and release
    runs-on: ubuntu-latest
    steps: 
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 16
      - name: Install root deps
        run: npm ci
      - name: Install package deps
        working-directory: packages/vue-quill
        run: npm ci
      - name: Release package
        working-directory: packages/vue-quill
        run: npx ts-node ../../scripts/release.ts vue-quill
        env: 
          GH_TOKEN: ${{ secrets.GH_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
luthfimasruri
  • 61
  • 2
  • 5
2

You can downgrade to version 2.77.4-1. That version works for me.

Adriaan
  • 17,741
  • 7
  • 42
  • 75