如何正确地将node_modules移动到不同的位置
我试图将我的node_modules移动到不同的位置,我所做的是删除node_modules,并将package.json移动到我希望它被安装的位置,然后运行npm install
,其中安装了node_modules,但是现在,如果我运行npm start
,服务器启动,我得到了很多错误:
(index):5 GET http://localhost:3000/node_modules/bootstrap/dist/css/bootstrap.min.css (index):9 GET http://localhost:3000/node_modules/es6-shim/es6-shim.min.js (index):10 GET http://localhost:3000/node_modules/systemjs/dist/system-polyfills.js (index):12 GET http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js (index):13 GET http://localhost:3000/node_modules/systemjs/dist/system.src.js (index):14 GET http://localhost:3000/node_modules/rxjs/bundles/Rx.js (index):15 GET http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js (index):16 GET http://localhost:3000/node_modules/angular2/bundles/http.dev.js (index):21 Uncaught ReferenceError: System is not defined(anonymous function) @ (index):21
我更新了index.html文件,以使用根目录node_modules中的文件而不是当前目录的node_modules。
还有什么我应该做的,以使其工作?
请注意,index.html与node_modules位于不同的目录中
解决scheme如下:
- 在包含package.json文件的目录下创buildbs-config.json文件
-
把下面的json放在那个bs-config.json文件中:
{“server”:{“baseDir”:“path / to / your / base / dir / where / you / have / the index.html / of / your / app”,“routes”:{“/ node_modules”: “/ path / to / node / modules / relative / to / this / file”}}}
-
编辑你的package.json文件
"lite": "lite-server --c bs-config.json"
- 运行
npm start
,它会像魔术一样工作:D
- Node.js Express App – Rickshaw.Graph.RangeSlider TypeError:$(element).slider不是函数
- 如何将node_modules安装到Docker镜像中,稍后再使用,而不需要docker撰写?
- Babel编译错误:找不到模块core-js / library / fn / get-iterator
- 在摩卡testing中没有发现柴的出口
- configurationrequirejs从node_modules读取
- 所需的节点/快递模块不更新与chokidar?
- 意外的input错误结束,这是第一次使用DiskDB
- 如何将项目的父文件夹中的node_modules设置为angular度cli
- 将节点模块variables注入到作用域