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.

With node target, Bluebird promise doesn't work because webpack uses package.json browser field instead of main field

See original GitHub issue

I’m submitting a bug report

Webpack version: 2.x

Please tell us about your environment: OSX 10.x

Current behavior:

With node target, Bluebird promise doesn’t work because webpack uses package.json browser field instead of main field.

  1. Create entry.js that uses bluebird and promisifyAll -
var Promise = require("bluebird");
var fs = Promise.promisifyAll(require("fs"))
  1. Run webpack with output.target = 'node' and output.pathinfo = true
  2. Open up bundle.js and search for bluebird.js

EXPECTING: Since I set the target as node, Webpack should have included ~/bluebird/js/release/bluebird.js.

ACTUAL: Webpack incorrectly included ~/bluebird/js/browser/bluebird.js.

If you look at https://github.com/petkaantonov/bluebird/blob/master/package.json there is a browser and a main field.

In addition, if you run node bundle.js you’ll get the following exception -

makeNodePromisified(key, THIS, key, fn, suffix, multiArgs); ^

TypeError: makeNodePromisified is not a function at promisifyAll (…) at Function.e.24.module.exports.Promise.promisifyAll (…)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
MrBlennycommented, Sep 24, 2016

It appears that target: 'electron-main' suffers the same issue and included the browser version not the node version.

0reactions
GuillaumeLeclerccommented, Oct 31, 2016

I have the same problem and I have target=‘node’ (in the config file not CLI though). @TheLarkInn I don’t see the update to this response.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack doesn't respect 'module' field in package.json
When module's package.json contains browser, module & main fields, webpack is bundling browser build by default.
Read more >
How WebPack decides what entry to load from a package.json
It will look first at the browser field, and if it doesn't exist, it'll look for the module , and lastly main ....
Read more >
Why the Hell Would I Use Node.js? A Case-by-case Tutorial
The browser catches the 'Send' button click through a JavaScript handler. It picks up the value from the input field (i.e., the message...
Read more >
Serverless Webpack in Lambda Simplified 101 - Learn | Hevo
This blog explains the different aspects of Serverless Webpack in Lambda. In addition to that, it describes AWS Lambda as well.
Read more >
Changelog - Bluebird JS
3.4.4 (2016-08-30). Bugfixes: Fix benchmark parallel in node 6 #1165; Fix memory leak with Promise ...
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