# Problems with require

**URL:** <https://forums.bitovi.com/t/problems-with-require/311>\
**Category:** StealJS\
**Created:** [June 13, 2016, 3:24pm UTC](https://forums.bitovi.com/t/problems-with-require/311 "2016-06-13T15:24:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ron.yuen](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@ron.yuen](https://forums.bitovi.com/u/ron.yuen)\
**Post date:** [June 13, 2016, 3:24pm UTC](https://forums.bitovi.com/t/problems-with-require/311/1 "2016-06-13T15:24:54Z")

</div>

Trying to get to grips with StealJS and following your example in stealjs website at guides - continuous builds’

([http://stealjs.com/docs/steal-tools.guides.watch\_mode.html](http://stealjs.com/docs/steal-tools.guides.watch_mode.html))

Everything works fine UPTO

var can = require(‘can’); (in Develop your application, about half way down the page)

All I get when I try to run it is a browser error that 'require is not a function.

wtf ???

I have run ‘npm install require --save’ and it is included in the node\_modules in the subdir as expected.

‘npm run build’ does not complain so I have NO F\*\* CLUE what is going on.

Help much appreciated.

I’m fairly experienced in the use of CanJS for complex applications but have not yet used steal/require/module loaders as my legacy technology restrictions make it very hard to integrate (js ‘files’ etc are in IDE binary blobs …) but I’m breaking out of the legacy into a trad file based setup, and smack into this.

Ron

---

<div class="post-metadata">

**Author:** ![matthewp](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/matthewp/32/77_2.png) [@matthewp](https://forums.bitovi.com/u/matthewp)\
**Post date:** [June 13, 2016, 3:38pm UTC](https://forums.bitovi.com/t/problems-with-require/311/2 "2016-06-13T15:38:49Z")

</div>

Hey @ron.yuen, sorry you’ve run into this problem. I’ll take a look at that guide and see if there’s a problem. In the mean time you might want to check out the [Quick Start](http://stealjs.com/docs/StealJS.quick-start.html) and then [Progressive Loading](http://stealjs.com/docs/steal-tools.guides.progressive_loading.html) guides which were recently updated.

---

<div class="post-metadata">

**Author:** ![ron.yuen](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@ron.yuen](https://forums.bitovi.com/u/ron.yuen)\
**Post date:** [June 13, 2016, 3:47pm UTC](https://forums.bitovi.com/t/problems-with-require/311/3 "2016-06-13T15:47:44Z")

</div>

Mathew

Quick off the mark !!

The bits you pointed at are fine, no issues. But so far I cannot ‘require’ anything which is sort of train smashish …

Just so you guys know I apprceiate the work that goes into this framework which has become an integral part of all the apps I do (for a BIG outfilt)

Ron

---

<div class="post-metadata">

**Author:** ![matthewp](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/matthewp/32/77_2.png) [@matthewp](https://forums.bitovi.com/u/matthewp)\
**Post date:** [June 13, 2016, 3:49pm UTC](https://forums.bitovi.com/t/problems-with-require/311/4 "2016-06-13T15:49:17Z")

</div>

Can you give a code example? Using `require` should be fine, but if you show me some code I can maybe help.

---

<div class="post-metadata">

**Author:** ![ron.yuen](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@ron.yuen](https://forums.bitovi.com/u/ron.yuen)\
**Post date:** [June 13, 2016, 4:46pm UTC](https://forums.bitovi.com/t/problems-with-require/311/5 "2016-06-13T16:46:55Z")

</div>

Matthew

The code is EXACTLY as per the webpage

[http://stealjs.com/docs/steal-tools.guides.progressive\_loading.html](http://stealjs.com/docs/steal-tools.guides.progressive_loading.html)

I have cut and paste into index.html,app.js,homepage.js,login.js etc and

IT ALL WORKS

But then I add  
var can = require(“can”);  
to app.js, run npm build and then run in the browser and it all falls over. ‘require is not a function’.

I have a require in node\_modules courtesy of ‘npm install require – save’ I notice, however, that there is no ‘require.js’ which I kindof expected to see

Am I installing the correct ‘require’ ???

The node and npm installations were made a couple of days ago and are ABSOLUTELY clean, no prior history.

I’m running nginx / openresty as the http server

If I use the ‘import can from ‘can’;’ syntax instead of require then it all works and I can go on to use can.stache / templates etc as I’m used to

the mere presence of the require() in the source triggers a collapse, this is what Firefox has to say

18:43:00.627 TypeError: require is not a function  
Stack trace:  
.execute@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js](http://localhost:8080/eSurvey2/node_modules/steal/steal.js) line 2890 \> eval:10:13  
doExecute@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:2135:7](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:2135:7)  
ensureEvaluated@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:2182:11](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:2182:11)  
doEnsureEvaluated@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:2145:15](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:2145:15)  
evaluateLoadedModule@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:2120:5](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:2120:5)  
Loader.prototype.import/\</\<@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:2310:20](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:2310:20)  
tryCatchReject@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:1183:28](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:1183:28)  
runContinuation1@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:1142:4](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:1142:4)  
makePromise/Fulfilled.prototype.when@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:930:4](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:930:4)  
makePromise/Pending.prototype.run@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:821:5](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:821:5)  
[3]\</\</\</Scheduler.prototype.\_drain@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:97:4](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:97:4)  
Scheduler/this.drain@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:62:4](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:62:4)  
run@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:268:4](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:268:4)  
.execute@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js](http://localhost:8080/eSurvey2/node_modules/steal/steal.js) line 2890 \> eval:10:13  
doExecute@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:2135:7](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:2135:7)  
ensureEvaluated@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:2182:11](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:2182:11)  
doEnsureEvaluated@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:2145:15](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:2145:15)  
evaluateLoadedModule@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:2120:5](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:2120:5)  
Loader.prototype.import/\</\<@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:2310:20](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:2310:20)  
tryCatchReject@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:1183:28](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:1183:28)  
runContinuation1@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:1142:4](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:1142:4)  
makePromise/Fulfilled.prototype.when@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:930:4](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:930:4)  
makePromise/Pending.prototype.run@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:821:5](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:821:5)  
[3]\</\</\</Scheduler.prototype.\_drain@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:97:4](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:97:4)  
Scheduler/this.drain@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:62:4](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:62:4)  
run@[http://localhost:8080/eSurvey2/node\_modules/steal/steal.js:268:4](http://localhost:8080/eSurvey2/node_modules/steal/steal.js:268:4)  
1 steal.js:6387:6  
 steal.js:6387  
tryCatchReject() steal.js:1183  
runContinuation1() steal.js:1142  
makePromise/Rejected.prototype.when() steal.js:963  
makePromise/Pending.prototype.run() steal.js:821  
[3]\</\</\</Scheduler.prototype.\_drain() steal.js:97  
Scheduler/this.drain() steal.js:62  
run() steal.js:268

---

<div class="post-metadata">

**Author:** ![fp\_dev](https://avatars.discourse-cdn.com/v4/letter/f/13edae/32.png) [@fp\_dev](https://forums.bitovi.com/u/fp_dev)\
**Post date:** [October 26, 2016, 7:49am UTC](https://forums.bitovi.com/t/problems-with-require/311/6 "2016-10-26T07:49:47Z")

</div>

Hi everybody,

I got the same problem ans I solved it.  
Working with this dependencies in package.json:

```
"dependencies": {
    "can": "^2.3.27",
    "jquery": "^2.2.4",
    "steal": "^0.16.41"
  }

```

@ron.yuen: do you have some multiline JS comment on your code (main.js) with “” inside?  
I had a multiline comment linke the following, because i was trying different modules import methods (AMD and CommonJS):

```
/* import can from "can";
   import $ from "jquery"
*/

```

When I removed them, and all start working correctly.  
I don’t know if is a steal problem or not but… lot of time seraching other, more complex issues, and at the end was this “nut”.
