如何正确地将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如下:

  1. 在包含package.json文件的目录下创buildbs-config.json文件
  2. 把下面的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”}}}

  3. 编辑你的package.json文件"lite": "lite-server --c bs-config.json"

  4. 运行npm start ,它会像魔术一样工作:D