gridsome-plugin-pwa
gridsome-plugin-pwa copied to clipboard
Export issue
I have the following error message in the console:
.../node_modules/register-service-worker/index.js:18
export function register (swUrl, hooks) {
^^^^^^
The export is not understood by const { register } = require('register-service-worker')
in gridsome.client.js
Just moving the code as follow solved the issue for me:
from
const { register } = require('register-service-worker');
const clientConfig = function (Vue, options, context) {
let {head, isClient} = context;
if (process.env.NODE_ENV === 'production' && isClient) {
to
const clientConfig = function (Vue, options, context) {
let {head, isClient} = context;
if (process.env.NODE_ENV === 'production' && isClient) {
const { register } = require('register-service-worker');
Thanks for opening issue! Please share a minimum reproducible repository.
Having same issue here.
Same issue here.
Here's my gridsome.config.js
:
const manifest = require('./static/manifest.json');
module.exports = {
siteName: 'SiteNameHere',
plugins: [
{
use: 'gridsome-plugin-manifest',
options: manifest
},
{
use: 'gridsome-plugin-pwa',
options: {
title: manifest.name,
startUrl: manifest.scope,
display: manifest.display,
statusBarStyle: 'default',
manifestPath: './static/manifest.json',
cachedFileTypes: 'js,json,css,html,png,jpg,jpeg,svg',
shortName: manifest.shortName,
themeColor: manifest.theme_color,
backgroundColor: manifest.background_color,
icon: manifest.icon_path,
msTileImage: manifest.icon_path,
msTileColor: manifest.theme_color
}
}
Changing the package by removing export
to module. exports = {register, unregister};
resolves the issue, although it's a hack that won't persist on fresh builds.
Same error