简体   繁体   中英

how to access package in public folder from node_modules folder in nodejs?

i have MEAN stack application. In public folder i have AngularJs application.

Structure

在此处输入图片说明

Here in index.html i am trying to access a package, which is present in node_modules .

Can any please tell me how to access this?

As @31Py said, you can reference using ../node_modules/path/to/the/package

OR

It's always better to create separate dependencies in package.json file for public folder(front end code). This helps you to organize both the code separate, while bundling front end, running task runners(grunt, gulp) and you would know which packages are for front end.
In index.html referencing the node modules will be /node_modules/path/to/the/package

Some reference Links with comments in the section.

  1. Separating Frontend & Backend Dependencies with Gulp/Yarn
  2. Separating package.json for frontend and backend with shared code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM