Closed andymjames closed 6 years ago
Thanks for letting us know! I'll try and have a look at this over the next couple of days.
Great! It just occurred to me that you probably want to reproduce it yourself...
I use webpack to give me one giant JS file I can upload to AWS to use as a Lambda function. You can probably repro the issue though by locally running a webpack output file as a Node app.
My webpack.config.js looks like this:
const path = require('path');
module.exports = {
entry: "./main-node-file.js",
output: {
path: path.join(__dirname, 'webpack-out'),
filename: "main-node-file.js",
libraryTarget: 'commonjs'
},
target: 'node'
};
That causes the output of using webpack to be a file of the same name as the main file, but in a sub dir called webpack-out
and the output file has all the dependencies also contained within the one file.
Since that one file is the only thing I send to AWS when that one Needle line tries to read a file at ../package.json
it doesn't exist. However webpack is smart enough that it would have included the contents of package.json in the mega-file output, had it been referenced via a require()
statement.
I hope that helps explain more and gives you a path towards repo'ing!
@davidlumley I was kind of hoping you'd have some initial feedback by now. Is there any more information I can provide?
I don't want to sound impatient, but this issue is blocking me from deploying a new service to production that will ultimately increase my company's Clearbit usage.
Hey @andymjames sorry for the delay, have been dealing with some more pressing matters.
Definitely don't want to block you though, so are you able to either: a) Fork this repo, add your change, and use that forkin your app b) Submit a PR with some clear tests that will enable me to quickly test and deploy
I've blocked time off to look at this, but want to make sure you've got a path forward in the meantime.
@davidlumley Do you know when this update will be published to NPM?
Has this fix been released? I am seeing issues trying to require clearbit using runkit: https://npm.runkit.com/clearbit
The Needle package you forked is where the issue lies. The way it gets the version out of package.json is incompatible with tools like Webpack and Browserify, which work better using a
require()
style syntax.In good news, the owner of the original repo found and fixed this over 2 years ago. https://github.com/tomas/needle/commit/f7a72f18ad554b2416471134834aaed950f32ee4
In more good news, it's a very straight forward 1 line fix.