backpack icon indicating copy to clipboard operation
backpack copied to clipboard

Should config.resolve.modules be undefined when overriding backpack?

Open gitleet opened this issue 7 years ago • 3 comments

I have a multi nodejs project setup like this:

project1
project2
shared
backpack.config.js
package.json

So I want to be able to reference the shared folder code from within my other projects. To do this I have to add path ./ to the NODE_PATH when I run my project1 for example:

"scripts": {
    "dev:project1": "cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env 
    DIR=api backpack"
  }

So I need to add the value of NODE_PATH to my resolve modules in the backpack config:

config.resolve.modules.push(nodePath);

Should the config.resolve.modules be undefined at this point? (that is what I am seeing) so I am doing this instead:

  config.resolve.modules = [nodePath];

The reason I am confused is because this other project that uses backpack is a .push call https://github.com/withspectrum/spectrum/blob/alpha/backpack.config.js#L36

When I try the same thing I can see that the modules array is actually undefined.

gitleet avatar Oct 22 '18 13:10 gitleet

Another thing I noticed is that now that I set the modules to [nodePath], when I start my app using

yarn run dev:project1

It only looks in ./node_modules not in ./project1/node_modules

So I didn't append the ./ to the module resolution lookup correctly.

Any tips?

gitleet avatar Oct 22 '18 16:10 gitleet

Hey @gitleet, did you ever get this resolved? I'm having the same issue.

jhalvorson avatar Mar 08 '19 18:03 jhalvorson

@jhalvorson just create it if it doesn't exist

config.resolve.modules = (config.resolve.modules || []).concat([nodePath])

schester44 avatar Nov 11 '19 21:11 schester44