Test Case: https://github.com/shaunstepanowich/stealjs-jquery-issue
Notes:
This test is based almost 100% on stealjs quick start guide
Main difference is the express server.
Pretty much all configuration is coming right out of NPM
Test Case is a nodejs app using express as the web server.
Steps:
Clone repo, run npm install
Run: grunt build
Run: node app.js (server is on localhost:8080)
In console in browser you’ll note the following:
localhost:8080/dist/bundles/main.js (successful request)
localhost:8080/jquery.js (404 request)
I think the main issue is that since you are loading steal from /steal, it does not know to use the NPM plugin.
One way to fix this is to change this line in your app.js
app.use('/steal',express.static(__dirname + '/node_modules/steal/'));
to
app.use('/node_modules', express.static(__dirname + '/node_modules/'));
and then change you Index.html to load steal from node_modules:
<script src="/node_modules/steal/steal.production.js" type="text/javascript" data-main="main"></script>
There are other ways to do this by setting configMain to package.json!npm
(see here ), so that you don’t have to expose all of node_modules. You may need to set other config options as well to get it to work though so it might be a little more complex.
Hi Kevin,
Thanks this helps a lot. I tried your suggestion and it did appear to work (in the test case at least)
I also took the steal.production.js file and put it into my own directory and then made it look like a node_modules directory:
app.use(’/node_modules/steal/’, express.static(__dirname + ‘/modules/steal/’));
This also seems to be working.
Is it really standard practice to expose node_modules directory as part of a web application, this seems very strange to me?
Thanks again.
pYr0x
April 5, 2016, 7:30am
4
you dont need to upload node_modules to your server. there a two ways:
@shaunstepanowich In development yes, we cannot load node_modules unless it is exposed. After you’ve done a build with steal-tools it will not need to have node_modules exposed.