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.

Uncaught TypeError: Cannot add property async, object is not extensible

See original GitHub issue

I keep getting Uncaught TypeError: Cannot add property async, object is not extensible when trying to pack my library with bili.

I hope I’m using the settings correctly. I’m trying to get my library to export a ES6 file and a normal and minified version of the file for browsers. I’m using yarn bili --format cjs,es,umd,umd-min --nodeResolve.preferBuiltins to bundle the files.

I’m using --nodeResolve.preferBuiltins as I use Buffer in my library and that fixes the issue of it not being mocked for the browser.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
egoistcommented, Feb 12, 2018

@OmgImAlexis no idea until I get home 😄 you should also use es modules

1reaction
egoistcommented, Feb 12, 2018

Hmm I don’t get the error Uncaught TypeError: Cannot add property async, object is not extensible after removed the async plugin (which transforms async to generator which buble can’t transform), just a bunch of warnings:

$ bili --moduleName Medusa --format cjs,es,umd,umd-min
⏳  Bundling 223 files: commonjs-proxy:/Users/egoist/dev/temp/medusa-lib/node_modules/qs/lib/parse.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳  Bundling 228 files: node_modules/iconv-lite/lib/index.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳  Bundling 231 files: node_modules/iconv-lite/encodings/internal.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳  Bundling 232 files: commonjs-external:buffer
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳  Bundling 232 files: commonjs-external:buffer
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable thi⏳  Bundling 233 files: commonjs-external:string_decoder
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable thi⏳  Bundling 233 files: commonjs-external:string_decoder
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable thi⏳  Bundling 234 files: node_modules/iconv-lite/encodings/utf16.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳  Bundling 235 files: node_modules/iconv-lite/encodings/utf7.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳  Bundling 236 files: node_modules/iconv-lite/encodings/sbcs-codec.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳  Bundling 239 files: node_modules/iconv-lite/encodings/dbcs-codec.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳  Bundling 265 files: node_modules/iconv-lite/lib/streams.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳  Bundling 267 files: node_modules/iconv-lite/lib/extend-node.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳  Bundling 314 files: commonjs-proxy:/Users/egoist/dev/temp/medusa-lib/node_modules/qs/lib/index.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⚠️  Using named and default exports together. Consumers of your bundle will have to use Medusa['default'] to access the default export, which may not be what you want. Use `exports: 'named'` to disable this warning
⚠️  Creating a browser bundle that depends on Node.js built-in modules ('buffer', 'url', 'http', 'https', 'zlib', 'stream', 'string_decoder', 'util' and 'tty'). You might need to include https://www.npmjs.com/package/rollup-plugin-node-builtins
⚠️  No name was provided for external module 'buffer' in options.globals – guessing 'require$$0'
⚠️  No name was provided for external module 'url' in options.globals – guessing 'require$$0$1'
⚠️  No name was provided for external module 'http' in options.globals – guessing 'http'
⚠️  No name was provided for external module 'https' in options.globals – guessing 'https'
⚠️  No name was provided for external module 'zlib' in options.globals – guessing 'zlib'
⚠️  No name was provided for external module 'stream' in options.globals – guessing 'require$$1'
⚠️  No name was provided for external module 'string_decoder' in options.globals – guessing 'require$$1$1'
⚠️  No name was provided for external module 'util' in options.globals – guessing 'util'
⚠️  No name was provided for external module 'tty' in options.globals – guessing 'tty'
⚠️  Using named and default exports together. Consumers of your bundle will have to use Medusa['default'] to access the default export, which may not be what you want. Use `exports: 'named'` to disable this warning
⚠️  Creating a browser bundle that depends on Node.js built-in modules ('buffer', 'url', 'http', 'https', 'zlib', 'stream', 'string_decoder', 'util' and 'tty'). You might need to include https://www.npmjs.com/package/rollup-plugin-node-builtins
⚠️  No name was provided for external module 'buffer' in options.globals – guessing 'require$$0'
⚠️  No name was provided for external module 'url' in options.globals – guessing 'require$$0$1'
⚠️  No name was provided for external module 'http' in options.globals – guessing 'http'
⚠️  No name was provided for external module 'https' in options.globals – guessing 'https'
⚠️  No name was provided for external module 'zlib' in options.globals – guessing 'zlib'
⚠️  No name was provided for external module 'stream' in options.globals – guessing 'require$$1'
⚠️  No name was provided for external module 'string_decoder' in options.globals – guessing 'require$$1$1'
⚠️  No name was provided for external module 'util' in options.globals – guessing 'util'
⚠️  No name was provided for external module 'tty' in options.globals – guessing 'tty'
✨  Built in 18.67s.
┌────────────────────────────────────────────┐
│file                    size       gzip size│
│dist/medusa-lib.cjs.js  301 B      149 B    │
│dist/medusa-lib.es.js   286 B      138 B    │
│dist/medusa-lib.js      978.81 KB  320.74 KB│
│dist/medusa-lib.min.js  308.91 KB  211.05 KB│
└────────────────────────────────────────────┘
✨  Done in 19.59s.

btw I should find a way to reduce duplicated warnings 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: can't define property "x": "obj" is not extensible
To fix this error, you will either need to remove the call to Object.preventExtensions() entirely, or move it to a position so that...
Read more >
Throwing an error TypeError: Cannot add property 0, object is ...
I'm starting with an array of User objects (users.mock.ts); Each Object is then map to ... These calls will not be made until...
Read more >
TypeError: can't define property "x": "obj" is not extensible
The JavaScript exception "can't define property "x": "obj" is not extensible" occurs when Object.preventExtensions() marked an object as no longer ...
Read more >
This Error is coming "Cannot add property count, object is not ...
It seems that with Spring 20, the response from apex has become non-extensible with additional parameters.
Read more >
TypeError: Cannot add property 0, object is not extensible ...
It looks like the docRef is undefined/null, so when you are trying to call the getDoc on an undefined value it fails. How...
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