Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gitleet opened this issue Oct 22, 2018 · 3 comments
Open

Comments

@gitleet
Copy link

gitleet commented Oct 22, 2018

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
Copy link
Author

gitleet commented Oct 22, 2018

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?

@jhalvorson
Copy link

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

@schester44
Copy link

@jhalvorson just create it if it doesn't exist

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants