0

I used Express generator to create node application. Directory structure looks like the following:

.
├── app.js
├── bin
│   └── www
├── package.json
├── public
│   ├── images
│   ├── javascripts
│   └── stylesheets
│       └── style.css
├── node_modules
│   └── jquery
│       └── dist
|            |___jquery.min.js
├── routes
│   ├── index.js
│   └── users.js
└── views
    ├── error.jade
    ├── index.jade
    └── layout.jade

In my index.jade file i try to reuse jquery.min.js from node_modules, instead use url to web source:

    doctype html
html
 head
 link(rel='stylesheet', href= '/stylesheets/style_monit.css')

body
 #container
  .row
   .col-sm-4(style='background-color:lavender;') .col-sm-4
   .col-sm-4(style='background-color:lavenderblush;') .col-sm-4     
   .col-sm-4(style='background-color:lavender;') .col-sm-4
   .col-md-4
    textarea#inData.form-control(style='background:#222; color:#00ff00;', rows='8')
 script(type='text/javascript' src='../node_modules/jquery/dist/jquery.min.js')

css file loads great, but in Chrome console i have error that

GET http://localhost:3000/node_modules/jquery/dist/jquery.min.js NOT FOUND

1 Answer 1

1

I believe the problem is that the node_modules directory is private and shouldn't be exposed to the client. Only static files in the public directory can be served. See this Stack Overflow answer for more information.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.