简体   繁体   English

如何从nodejs的node_modules文件夹访问公用文件夹中的包?

[英]how to access package in public folder from node_modules folder in nodejs?

i have MEAN stack application. 我有MEAN stack应用程序。 In public folder i have AngularJs application. 在公用文件夹中,我有AngularJs应用程序。

Structure 结构体

在此处输入图片说明

Here in index.html i am trying to access a package, which is present in node_modules . 我在index.html尝试访问一个包,该包位于node_modules

Can any please tell me how to access this? 可以请告诉我如何访问吗?

As @31Py said, you can reference using ../node_modules/path/to/the/package 正如@ 31Py所说,您可以使用../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). 最好在package.json文件中为公用文件夹(前端代码)创建单独的依赖项。 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. 这有助于您将两个代码分开组织,同时捆绑前端,运行任务运行程序(grunt,gulp),并且您会知道哪些软件包用于前端。
In index.html referencing the node modules will be /node_modules/path/to/the/package 在index.html中,引用的节点模块将是/node_modules/path/to/the/package

Some reference Links with comments in the section. 本节中一些带有注释的参考链接。

  1. Separating Frontend & Backend Dependencies with Gulp/Yarn 使用Gulp / Yarn分离前端和后端依赖项
  2. Separating package.json for frontend and backend with shared code 使用共享代码将package.json分离为前端和后端

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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