1

I am trying to loop over array of strings and require them with require and for some reason this is not working.

This is working:

console.log(require('./siteParts/testis')); 

This is not:

var siteParts = ['testis']; siteParts.forEach(function(part) { console.log(require('./siteParts/' + part)); Error: Cannot find module './siteParts/testis' }); 

1 Answer 1

1

I'm afraid this is [status-bydesign], to use the SE terminology. Browserify uses naive parsing of the text, and only searches for a normal require('some module name'). Anything dynamically parsed isn't going to be included.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.