debug icon indicating copy to clipboard operation
debug copied to clipboard

Why not include 'dist' folder in npm package?

Open stevenjlho opened this issue 10 years ago • 20 comments

When i use webpack to compile file, console show these error message.

ERROR in debug (bower component)
Module not found: Error: Cannot resolve 'file' or 'directory' ./dist/debug.js in /Users/stevenjlho/Work/v4s/htdocs/node_modules/debug
@ debug (bower component) 1:17-43

Npm package version is 2.2.0.

stevenjlho avatar Dec 16 '15 04:12 stevenjlho

i have the same problem

strayiker avatar Dec 28 '15 16:12 strayiker

+1

AndrejGajdos avatar Dec 30 '15 17:12 AndrejGajdos

Is there a reason that webpack thinks its a bower component rather than an npm module?

TooTallNate avatar Dec 30 '15 18:12 TooTallNate

I had to npm install debug && cd debug && make in order for the dist directory to show up. Not sure if that's by design or not.

nathasm avatar Jan 05 '16 21:01 nathasm

@TooTallNate probably the bower.json file

stephenmathieson avatar Jan 05 '16 21:01 stephenmathieson

Maybe we just remove it?

TooTallNate avatar Jan 06 '16 00:01 TooTallNate

idk.. sounds like having bower support breaks webpack support. i don't use either so i'd say remove all the things =)

stephenmathieson avatar Jan 06 '16 00:01 stephenmathieson

Maybe I use Bower Webpack Plugin, when I remove this plugin, console don't show error message.

stevenjlho avatar Jan 06 '16 05:01 stevenjlho

+1

stepek avatar Jan 08 '16 06:01 stepek

Same problem here.

adamcharnock avatar Jan 12 '16 10:01 adamcharnock

Could you please publish a new release with the dist/ folder included? I can see that you disabled this in 43b0d51, but it is needed by everyone not using a module loader (or one, that is not compatible).

nhaesler avatar Jan 17 '16 18:01 nhaesler

+1 , i am getting the same error >> ERROR in debug (bower component) Module not found: Error: Cannot resolve 'file' or 'directory' ./dist/debug.js in D:\oms\node_modules\debug @ debug (bower component) 1:17-43 Inside the debug directory there is no directory dist . MakeFile in the debug directory says

all: dist/debug.js
Is this is the reason which is causing it?

gitsubham avatar Jan 19 '16 06:01 gitsubham

@gitsubham Are you using Webpack too? It seems weird, that a npm package is recognized as a bower component. It looks like webpack supports all kinds of JS module formats, so you should be able to just include the browser.js in the package. With a module loader you should not need the dist/ folder.

As an alternative you could require my fork https://github.com/nhaesler/debug.git#100cf7e, so you'll get the dist/ folder, until my PR #251 is merged.

nhaesler avatar Jan 19 '16 11:01 nhaesler

How about appending bower.json to .npmignore?

huntout avatar Jan 25 '16 10:01 huntout

How about appending bower.json to .npmignore?

that makes sense to me

stephenmathieson avatar Jan 27 '16 17:01 stephenmathieson

@nathasm thank you, it worked out

cema-sp avatar Feb 01 '16 15:02 cema-sp

For anyone using bower-webpack-plugin: The main issue is that it is recognizing the npm package as a bower component. This is because of this setting: searchResolveModulesDirectories. It is set to true by default and thus searches for the bower components in resolve.modulesDirectories. This probably points to your node_modules directory which is causing the plugin to see the npm package as a bower component. To resolve, simply set this as false in your webpack config. Hope this helps!


{
plugins: [new BowerWebpackPlugin({
      modulesDirectories: [path],
      manifestFiles:      "bower.json",
      includes:           /.*/,
      excludes:           [],
      searchResolveModulesDirectories: false
    })]
}

ShubhamGupta avatar Aug 12 '16 08:08 ShubhamGupta

There is no need to disable searchResolveModulesDirectories. Just add node_modules to the excludes array.

plugins: [
    new BowerWebpackPlugin({ excludes: ['node_modules'] })
]

HardlyMirage avatar Sep 05 '16 11:09 HardlyMirage

@ShubhamGupta, @HardlyMirage what if you want to install some Bower package with npm/yarn (so you do not want to exclude node_modules from BowerWebpackPlugin)?

For example: angular-bootstrap-toggle can be installed as Node-dependency but it does not use any module system because it just an Bower-package.

sza-1 avatar Oct 28 '16 09:10 sza-1

Closing this for now.

thebigredgeek avatar Dec 14 '16 22:12 thebigredgeek