Wednesday 10 May 2017

Webpack can't find npm link'd module

I'm working on two Node.js packages. One is a Vue.js component and the other is a project that will use it. I'll call them library and consumer respectively.

This is what I've done so far:

  1. cd library && npm link && cd .. (link library globally)
  2. cd consumer && npm link library (register it with consumer)

Now when I try to run webpack-dev-server in consumer I get an error:

Module not found: Error: Can't resolve 'library' in 'C:\Projects\consumer\src'

When I look in the consumer's node_modules I see a symlink to the library, but for some reason webpack isn't resolving it.

I've been looking over this widely-cited help doc about webpack + npm link, which recommends adding path.join(__dirname, 'node_modules') to resolve.modules, but I'm still getting the same error.

This is on Windows but I've tried the same process on a Linux machine with the same result.

Has anyone been successful in getting webpack to work with npm link?



via Jura

No comments:

Post a Comment