The structure of Express is as follows:
|---node_modules------for installing local modules.
|---Public------------is used to store files, slices, script files, style sheets, etc. that users can download to.
|---Routes------------used to store routing files.
|---Views-------------templates for storing web pages.
|---the startup script for the App.js------------application.
|---The configuration file for the Package.json------project.
From the above structure, we know to put the local file into public, such as the script file JS file can be placed in the public folder JavaScripts. The answer to why it doesn't work in other places is as follows: The procedure for introducing a static file in App.js is as follows: App.use (Express.static (Path.join (__dirname, ' public '));//__ DirName is the absolute path when the program executes. In this way, the introduction of local files is indicated. So it is reasonable to put the local files into public, the following is the specific use in Express Ejs. For example, to introduce a local bootpicker.js file, simply add the code to the HTML head:
<Script src="/javascripts/datepicker.js" type="Text/javascript"></script>
when the browser issued a non-HTML file request, the server side to the public directory to find JavaScripts, and then to javascripts under the search for bootpicker.js files.
How to introduce local files under Nodejs Express