question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

rollup-plugin-workbox 5.2.0 error: [!] SyntaxError: Cannot use import statement outside a module

See original GitHub issue

My builds failed on this newest version of the plugin. The full error was:

[!] SyntaxError: Cannot use import statement outside a module
C:\D2L\personal\brightspaceui-core-bundler\node_modules\rollup-plugin-workbox\dist\index.js:1
import { generateSW as _generateSw, injectManifest as _injectManifest, } from 'workbox-build';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1054:16)
    at Module._compile (internal/modules/cjs/loader.js:1102:27)
    at Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Object.require.extensions.<computed> [as .js] (C:\D2L\personal\brightspaceui-core-bundler\node_modules\rollup\dist\shared\loadConfigFile.js:511:13)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\D2L\personal\brightspaceui-core-bundler\node_modules\@open-wc\building-rollup\src\createSpaConfig.js:9:24)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)

Reverting to version 5.1.0 solved the issue. Do I need to change something to work with the newest version of the plugin?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
RageCage64commented, Aug 22, 2020

Thanks for fixing that @thepassle it works now!

1reaction
thepasslecommented, Aug 21, 2020

Thanks for reporting, and sorry about that! This should be fixed in https://github.com/modernweb-dev/web/pull/407

Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntaxError: Cannot use import statement outside a module
But that gets me another error: "Error: Plugin/Preset files are not allowed to export objects, only functions." Here are the dependencies I ...
Read more >
SyntaxError: Cannot use import statement outside a module ...
When you use ECMAScript Modules in Node (v13.6.0 for me) combined with Jest, the following error occurs: SyntaxError: Cannot use import ...
Read more >
How to Fix "SyntaxError: Cannot use import statement outside ...
In this post, we'll learn more about the "SyntaxError: Cannot use import statement outside a module" error and how to fix it in...
Read more >
Cannot use import statement outside a module [React ...
In this article, you'll learn how to fix the SyntaxError: Cannot use import statement outside a module error when using TypeScript or JavaScript ......
Read more >
SyntaxError: Cannot use import statement outside a module
SyntaxError : Cannot use import statement outside a module ... Debugger attached. (node:11959) Warning: To load an ES module, set "type": "module" in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found