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.

`Object.defineProperty called on non-object`

See original GitHub issue

Environment


  • Operating System: Linux
  • Node Version: v16.15.1
  • Nuxt Version: 3.0.0-rc.4
  • Package Manager: pnpm@7.2.1
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

create a fresh project and open it on a browser

pnpx nuxt@rc init nuxt-app
cd nuxt-app/
pnpm install --shamefully-hoist
pnpm dev -o

and open http://localhost:3000/

Describe the bug

Nuxt CLI v3.0.0-rc.4

  > Local:    http://localhost:3000/ 
  > Network:  http://192.168.32.128:3000/
  > Network:  http://172.17.0.1:3000/

ℹ Vite client warmed up in 746ms
ℹ Vite server warmed up in 153ms
✔ Vite server built in 1223ms
✔ Nitro built in 298 ms
[nuxt] [request error] Object.defineProperty called on non-object
  at Function.defineProperty (<anonymous>)  
  at $id_a7972da4 (./.nuxt/dist/server/server.mjs:129:8)  
  at __instantiateModule__ (./.nuxt/dist/server/server.mjs:20116:9)  
  at __ssrLoadModule__ (./.nuxt/dist/server/server.mjs:20054:25)  
  at ssrImport (./.nuxt/dist/server/server.mjs:20079:13)  
  at $id_fe0c645f (./.nuxt/dist/server/server.mjs:17:37)  
  at __instantiateModule__ (./.nuxt/dist/server/server.mjs:20116:9)  
  at __ssrLoadModule__ (./.nuxt/dist/server/server.mjs:20054:25)  
  at ./.nuxt/dist/server/server.mjs:20131:22  
  at ModuleJob.run (node:internal/modules/esm/module_job:198:25)

the offending line is

Object.defineProperty(exports, '__esModule', { value: true });

Additional context

skeleton project pushed to https://gitlab.com/mnemoc/nuxt3-pnpm-issue-5516

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
danielroecommented, Nov 2, 2022

I think this should no longer be the case as we now use vite-node as the default devBundler. If you are still experiencing this, please feel free to provide a reproduction and I will reopen.

0reactions
kasvithcommented, Aug 23, 2022

Im also getting this with transpiling @ant-design/icons-vue

My module

export default defineNuxtModule({
  meta: {
    // Usually  npm package name of your module
    name: "antdv",
    // The key in `nuxt.config` that holds your module options
    configKey: "antdv",
    // Compatibility constraints
    compatibility: {
      // Semver version of supported nuxt versions
      nuxt: "^3.0.0",
    },
  },
  // Default configuration options for your module
  defaults: {},
  hooks: {},
  async setup (moduleOptions, nuxt) {
    nuxt.options.build.transpile.push('lodash-es', 'dayjs')

    nuxt.options.vite.optimizeDeps = nuxt.options.vite.optimizeDeps || {}
    nuxt.options.vite.optimizeDeps.include = nuxt.options.vite.optimizeDeps.include || []
    nuxt.options.vite.optimizeDeps.include.push('ant-design-vue')
    nuxt.options.vite.optimizeDeps.include.push('@ant-design/icons-vue')
    AntDComponents.map((name) =>
      addComponent({
        name: `A${name}`,
        export: `${name}`,
        filePath: "ant-design-vue",
      })
    );

    const antdIconsRequire = createRequire(import.meta.url)

    addComponentsDir({
      path: join(dirname(antdIconsRequire.resolve('@ant-design/icons-vue'))),
      pathPrefix: false,
      transpile: true
    })
  },
});

JS output where error occures

// --------------------
// Request: /node_modules/@ant-design/icons-vue/lib/icons/StepBackwardOutlined.js
// Parents: 
// - /pages/login.vue?macro=true ($id_ITuqivn9Dh)
// - /pages/login.vue ($id_sJIhc9o139)
// Dependencies: 

// --------------------
const $id_NdjBnO56iT = async function (global, module, exports, __vite_ssr_exports__, __vite_ssr_import_meta__, __vite_ssr_import__, __vite_ssr_dynamic_import__, __vite_ssr_exportAll__) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _vue = require("vue");

var _StepBackwardOutlined = _interopRequireDefault(require("@ant-design/icons-svg/lib/asn/StepBackwardOutlined"));

var _AntdIcon = _interopRequireDefault(require("../components/AntdIcon"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var StepBackwardOutlined = function StepBackwardOutlined(props, context) {
  var p = _objectSpread({}, props, context.attrs);

  return (0, _vue.createVNode)(_AntdIcon["default"], _objectSpread({}, p, {
    "icon": _StepBackwardOutlined["default"]
  }), null);
};

StepBackwardOutlined.displayName = 'StepBackwardOutlined';
StepBackwardOutlined.inheritAttrs = false;
var _default = StepBackwardOutlined;
exports["default"] = _default;;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Object.defineProperty called on non-object JQUERY
I have this error in Jquery when I try to each an array of HTML elements and handle onclick of that element. Object.keys(collapsibles).forEach( ......
Read more >
Uncaught TypeError: Object.defineProperty called on non ...
bug report Using Parcel 2.0.0-beta.1, react relay and yarn workspaces, produces a non-working build. Using the option no-scope-hoist fixes ...
Read more >
Object.defineProperty() - JavaScript - MDN Web Docs
defineProperty() defines a new property directly on an object, or modifies an existing property on an object, and returns the object.
Read more >
jquery error - WordPress.org
i am getting this error after updating to WordPress 5.6 (latest version):. Uncaught TypeError: Object.defineProperty called on non-object in jquery.min.js:2.
Read more >
TypeError: Object.defineProperty called on non-object JQUERY
I have this error in Jquery when I try to each an array of HTML elements and handle onclick of that element. Object.keys(collapsibles).forEach(function...
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