Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receiving Cannot read properties of undefined (reading 'get') on version 0.6.1 #481

Closed
dnlsndr opened this issue Jan 31, 2022 · 22 comments
Closed

Comments

@dnlsndr
Copy link

dnlsndr commented Jan 31, 2022

Version 0.6.1 broke something when running nuxt generate and I'm not sure what it is.

Please see the error I get below:

FATAL  Cannot read properties of undefined (reading 'get')

  at _interopNamespace (node_modules/@nuxt/image/dist/module.js:26:39)
  at node_modules/@nuxt/image/dist/module.js:290:83
  at async ModuleContainer.imageModule2 (node_modules/@nuxt/image/dist/module.js:290:20)
  at async ModuleContainer.addModule (node_modules/@nuxt/core/dist/core.js:239:20)
  at async ModuleContainer.ready (node_modules/@nuxt/core/dist/core.js:55:5)
  at async Nuxt._init (node_modules/@nuxt/core/dist/core.js:478:5)

   ╭────────────────────────────────────────────────────────────────────╮
   │                                                                    │
   │   ✖ Nuxt Fatal Error                                               │
   │                                                                    │
   │   TypeError: Cannot read properties of undefined (reading 'get')   │
   │                                                                    │
   ╰────────────────────────────────────────────────────────────────────╯

Nuxt version: 2.15.8

@dnlsndr dnlsndr changed the title Receiving Cannot read properties of undefined (reading 'get') on version 0.6.1 Receiving Cannot read properties of undefined (reading 'get') on version 0.6.1 Jan 31, 2022
@leo91000
Copy link

leo91000 commented Jan 31, 2022

I am having the same problem (upgraded from 0.6.0 to 0.6.1)

I am on nuxt bridge

@Suhov1985
Copy link

I am having the same problem (upgraded from 0.6.0 to 0.6.1)

@Paalt
Copy link

Paalt commented Feb 1, 2022

I am having the same problem (upgraded from 0.6.0 to 0.6.1)
I am on nuxt 2

@ldrummond
Copy link

Bump

@jamaluddinrumi
Copy link

same happened with me after upgraded 0.6.0 to 0.6.1 using nuxt 2

@ivaneliasoo
Copy link

same situation happenning here on Nuxt 2.15.8

@pi0
Copy link
Member

pi0 commented Feb 2, 2022

Traceback seems related to the lru-cache import but I cannot reproduce it with a fresh installation of 2.15/2.16 with/without bridge and nuxt generate.

Can you please try to recreate lockfile (package.lock.json / yarn.lock) if it solves issue or not?

@bezin
Copy link

bezin commented Feb 2, 2022

Even though I am pretty sure I did exactly this before, I deleted yarn.lock and ran yarn install && yarn upgrade and now it is fixed for me 👍

Edit: Nope, sorry, did not solve it after all :/

@dnlsndr
Copy link
Author

dnlsndr commented Feb 2, 2022

I'll try to come up with a reproduction

@Kyun-J
Copy link

Kyun-J commented Feb 3, 2022

I am having the same problem

@jeanmatthieud
Copy link
Contributor

Same issue here with 0.6.1. Works fine with 0.6.0.

@dnlsndr
Copy link
Author

dnlsndr commented Feb 5, 2022

Anybody care to post their nuxt config and package.json? I'm currently trying to reproduce this issue in a fresh repo, but am not able to. Would help to figure out commonalities such that the issue is easier to pinpoint.

@svenjungnickel
Copy link

I am having the same issue since the update from 0.6.0 to 0.6.1 running nuxt 2.

Here my package.json

{
  "name": "svenjungnickel",
  "version": "1.0.0",
  "private": true,
  "engines": {
    "node": ">=16"
  },
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
    "lint:style": "stylelint \"**/*.{css,scss,sass,html,vue}\" --ignore-path .gitignore",
    "lint:prettier": "prettier --check .",
    "lint": "npm run lint:js && npm run lint:style && npm run lint:prettier",
    "lintfix": "prettier --write --list-different . && npm run lint:js -- --fix && npm run lint:style -- --fix",
    "prepare": "husky install",
    "test": "jest"
  },
  "lint-staged": {
    "*.{js,vue}": "eslint --cache",
    "*.{css,scss,sass,html,vue}": "stylelint",
    "*.**": "prettier --check --ignore-unknown"
  },
  "dependencies": {
    "@nuxt/content": "^1.15.1",
    "@nuxtjs/pwa": "^3.3.5",
    "core-js": "^3.21.0",
    "nuxt": "^2.15.8",
    "vue": "^2.6.14",
    "vue-server-renderer": "^2.6.14",
    "vue-template-compiler": "^2.6.14",
    "webpack": "^4.46.0"
  },
  "devDependencies": {
    "@babel/eslint-parser": "^7.17.0",
    "@commitlint/cli": "^16.1.0",
    "@commitlint/config-conventional": "^16.0.0",
    "@nuxt/image": "^0.6.1",
    "@nuxtjs/eslint-config": "^8.0.0",
    "@nuxtjs/eslint-module": "^3.0.2",
    "@nuxtjs/stylelint-module": "^4.1.0",
    "@nuxtjs/svg": "^0.4.0",
    "@nuxtjs/tailwindcss": "^4.2.1",
    "@vue/test-utils": "^1.3.0",
    "babel-core": "7.0.0-bridge.0",
    "babel-jest": "^27.4.6",
    "eslint": "^8.8.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-nuxt": "^3.1.0",
    "eslint-plugin-vue": "^8.4.0",
    "husky": "^7.0.4",
    "jest": "^27.4.7",
    "lint-staged": "^12.3.3",
    "postcss": "^8.4.6",
    "postcss-html": "^1.3.0",
    "prettier": "^2.5.1",
    "sass": "^1.49.7",
    "sass-loader": "^10.2.0",
    "stylelint": "^14.3.0",
    "stylelint-config-prettier": "^9.0.3",
    "stylelint-config-recommended-vue": "^1.1.0",
    "stylelint-config-standard": "^24.0.0",
    "vue-jest": "^3.0.4"
  }
}

And here my nuxt.config.js

export default {
  // Target: https://go.nuxtjs.dev/config-target
  target: 'static',

  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: 'svenjungnickel.com',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
      { name: 'format-detection', content: 'telephone=no' },
    ],
    link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
  },

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: [
    '@/assets/css/tailwind.scss'
  ],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    // https://go.nuxtjs.dev/eslint
    '@nuxtjs/eslint-module',
    // https://go.nuxtjs.dev/stylelint
    '@nuxtjs/stylelint-module',
    // https://go.nuxtjs.dev/tailwindcss
    '@nuxtjs/tailwindcss',
    // https://image.nuxtjs.org/
    '@nuxt/image',
    // https://github.com/nuxt-community/svg-module
    '@nuxtjs/svg'
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    // https://go.nuxtjs.dev/pwa
    '@nuxtjs/pwa',
    // https://go.nuxtjs.dev/content
    '@nuxt/content',
  ],

  // PWA module configuration: https://go.nuxtjs.dev/pwa
  pwa: {
    manifest: {
      lang: 'en',
    },
  },

  // Content module configuration: https://go.nuxtjs.dev/config-content
  content: {},

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {},

  image: {
    presets: {
      profile: {
        modifiers: {
          format: 'webp',
          quality: 80
        }
      }
    }
  }
}

@dnlsndr
Copy link
Author

dnlsndr commented Feb 6, 2022

Thanks! I can already make out tailwind and nuxt content, which we are also using.

@riccardolardi
Copy link

riccardolardi commented Feb 9, 2022

I think it's related to Rollup:

function _interopNamespace(e) {
  if (e && e.__esModule) return e;
  const n = Object.create(null);
  if (e) {
    for (const k in e) {
      if (k !== 'default') {
        const d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : { // <--- this breaks since d is undefined
          enumerable: true,
          get: function () { return e[k]; }
        });
      }
    }
  }
  n["default"] = e;
  return Object.freeze(n);
}

Temporary fix Adding optional chaining solves the issue in my case and lets the build succeed:
Object.defineProperty(n, k, d?.get ? d : {

The _interopNamespace function is part of Rollup's esModuleInterop functionality: https://rollupjs.org/guide/en/#outputinterop

@MichaelPrecel
Copy link

MichaelPrecel commented Feb 11, 2022

I'm having this same problem —

{
  "name": "goldi",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "nuxi dev",
    "build": "nuxi build",
    "start": "nuxi preview",
    "generate": "nuxi generate",
    "lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
    "lint:prettier": "prettier --check .",
    "lint": "yarn lint:js && yarn lint:prettier",
    "lintfix": "prettier --write --list-different . && yarn lint:js --fix"
  },
  "dependencies": {
    "@nuxt/http": "^0.6.4",
    "@nuxt/image": "^0.6.0",
    "@nuxtjs/sanity": "^0.10.0",
    "@pinia/nuxt": "^0.1.8",
    "@sanity/client": "^2.23.2",
    "@vueuse/nuxt": "^7.6.1",
    "core-js": "^3.19.3",
    "flickity": "^2.3.0",
    "include-media": "^1.4.10",
    "lodash.throttle": "^4.1.1",
    "marquee3000": "^1.1.1",
    "nuxt-edge": "latest",
    "picosanity": "^3.0.3",
    "pinia": "^2.0.11",
    "reset-css": "^5.0.1",
    "sass": "^1.49.7",
    "sass-loader": "10",
    "vue": "^2.6.14",
    "vue-plyr": "^7.0.0",
    "vue-server-renderer": "^2.6.14",
    "vue-template-babel-compiler": "^1.1.3",
    "vue-template-compiler": "^2.6.14",
    "webpack": "^4.46.0"
  },
  "devDependencies": {
    "@babel/eslint-parser": "^7.16.3",
    "@nuxt/bridge": "npm:@nuxt/bridge-edge",
    "@nuxtjs/eslint-config": "^8.0.0",
    "@nuxtjs/eslint-module": "^3.0.2",
    "eslint": "^8.4.1",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-nuxt": "^3.1.0",
    "eslint-plugin-vue": "^8.2.0",
    "prettier": "^2.5.1"
  }
}
import { defineNuxtConfig } from '@nuxt/bridge'

export default defineNuxtConfig({
  // Target: https://go.nuxtjs.dev/config-target
  target: 'static',

  generate: {
    fallback: true,
  },

  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: 'goldi',
    htmlAttrs: {
      lang: 'en',
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
      { name: 'format-detection', content: 'telephone=no' },
    ],
    link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
  },

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: ['reset-css', '@/assets/css/main.scss'],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [
    // '~/plugins/init.server.js',
    '~/plugins/preview.client.js',
    '~/plugins/flickity/index.client.js',
    '~/plugins/vue-plyr.client.js',
  ],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    // https://go.nuxtjs.dev/eslint
    '@nuxtjs/eslint-module',
    '@vueuse/nuxt',
    '@nuxt/image',
    '@nuxtjs/sanity/module',
    ['@pinia/nuxt', { disableVuex: true }],
  ],

  sanity: {
    projectId: 'xxx',
    dataset: 'production',
  },

  image: {
    sanity: {
      projectId: 'xxx',
      withCredentials: true,
    },
    domains: ['https://cdn.shopify.com', 'https://cdn.sanity.io'],
  },

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: ['@nuxt/http'],

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    transpile: ['pinia'],
    loaders: {
      vue: {
        compiler: require('vue-template-babel-compiler'),
      },
    },
  },

  bridge: {
    nitro: false,
    // vite: true,
  },

  http: {
    baseUrl:
      process.env.NODE_ENV !== 'production'
        ? 'http://localhost:8888'
        : 'https://xxx.netlify.app',
  },

  router: {
    middleware: ['nuxt-server-init'],
  },
})

After much consternation, the workaround from @riccardolardi above has fixed it. However this won't provide much help once I try to deploy through Netlify as it'll grab the regular package!

@Asingerdev
Copy link

Same issue here, working locally but cannot deploy through Netlify

@dnlsndr
Copy link
Author

dnlsndr commented Feb 13, 2022

@MichaelPrecel Seems like we have almost no packages in common, so the issue most probably really lies with nuxt or nuxt-image rollup.

@provok-me
Copy link

Exactly the same problem here!

@MichaelPrecel
Copy link

Hi all, rolling back to 0.6.0 from 0.6.1 has resolved the issue!

@Saurou
Copy link

Saurou commented Feb 15, 2022

Nuxt 2.15.8

I seem to get this error with 0.6.1, on a new project, when I make changes in nuxt.config.js

On an existing project, upgrading to 0.6.1 gives me constant error, and only downgrading to 0.6.0 solves it.

@pi0 pi0 closed this as completed in 61bcb90 Feb 17, 2022
@pi0
Copy link
Member

pi0 commented Feb 17, 2022

The issue should be solved in 0.6.2.

procrates pushed a commit to procrates/nuxt-image that referenced this issue Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests