2

I am trying to move my node_modules to a different location, what I did is deleted the node_modules and moved the package.json to the location I wanted it to be installed, then I ran npm install which installed the node_modules where I wanted but now, if I run npm start, the server starts and I get alot of errors:

(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

I updated the index.html file to use the files from root node_modules instead of current dir's node_modules.

What else am I supposed to do to make it work?

Notice that the index.html is in a differnt dir then the node_modules

Ron
  • 3,975
  • 17
  • 80
  • 130
  • Possible duplicate of [Change node\_modules location](http://stackoverflow.com/questions/18974436/change-node-modules-location) – James P May 29 '16 at 20:37

1 Answers1

1

The solution is as follow:

  1. Create bs-config.json file at the same dir where you have package.json file
  2. Put the following json in that bs-config.json file:

    { "server": { "baseDir": "path/to/your/base/dir/where/you/have/the/index.html/of/your/app", "routes": { "/node_modules": "/path/to/node/modules/relatively/to/this/file" } } }

  3. Edit your package.json file "lite": "lite-server --c bs-config.json"

  4. Run npm start and it will work like a magic :D
Ron
  • 3,975
  • 17
  • 80
  • 130
  • I tried this way but didn't worked for me. I want to do this, can you please share your folder structure and paths in `bs-config.json` file so that I can check. OR share sample version in plnkr.co/edit/?p=preview? – immayankmodi Aug 14 '16 at 11:21