myfunc / chatServer

Simple realtime chat on Node.js
0 stars 0 forks source link

install dependencies locally #1

Open vredchenko opened 8 years ago

vredchenko commented 8 years ago

FYI: If you do npm init in your project root directory, that will interactivelly guide you through a bunch of choices (stick with the defaults for now) and create a basic package.json file. When you later realise you need a node dependency - you can do npm install node-static --save or npm install node-static --save-dev - that will write the dependency into package.json and install it locally into node_modules folder, rather than system-wide. Your project scripts will still be able to find it, no changes to require are required. Then if someone else clones your repo all they have to do is run npm install and all the dependencies listed in package.json will be installed automatically, which is pretty convenient

vredchenko commented 8 years ago

Here's what an example package.json may look like, not the scripts section:

{
  "name": "angular-seed",
  "private": true,
  "version": "0.0.0",
  "description": "A starter project for AngularJS",
  "repository": "https://github.com/angular/angular-seed",
  "license": "MIT",
  "devDependencies": {
    "bower": "^1.7.7",
    "http-server": "^0.9.0",
    "jasmine-core": "^2.4.1",
    "karma": "^0.13.22",
    "karma-chrome-launcher": "^0.2.3",
    "karma-firefox-launcher": "^0.1.7",
    "karma-jasmine": "^0.3.8",
    "karma-junit-reporter": "^0.4.1",
    "protractor": "^3.2.2"
  },
  "scripts": {
    "postinstall": "bower install",

    "prestart": "npm install",
    "start": "http-server -a localhost -p 8000 -c-1 ./app",

    "pretest": "npm install",
    "test": "karma start karma.conf.js",
    "test-single-run": "karma start karma.conf.js --single-run",

    "preupdate-webdriver": "npm install",
    "update-webdriver": "webdriver-manager update",

    "preprotractor": "npm run update-webdriver",
    "protractor": "protractor e2e-tests/protractor.conf.js",

    "update-index-async": "node -e \"var fs=require('fs'),indexFile='app/index-async.html',loaderFile='app/bower_components/angular-loader/angular-loader.min.js',loaderText=fs.readFileSync(loaderFile,'utf-8').split(/sourceMappingURL=angular-loader.min.js.map/).join('sourceMappingURL=bower_components/angular-loader/angular-loader.min.js.map'),indexText=fs.readFileSync(indexFile,'utf-8').split(/\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/).join('//@@NG_LOADER_START@@\\n'+loaderText+'    //@@NG_LOADER_END@@');fs.writeFileSync(indexFile,indexText);\""
  }
}
myfunc commented 8 years ago

Thanks, Val. I'l fix it later... 20 Июн 2016 г. 16:03 пользователь "Val Redchenko" notifications@github.com написал:

Here's what an example package.json may look like, not the scripts section:

{ "name": "angular-seed", "private": true, "version": "0.0.0", "description": "A starter project for AngularJS", "repository": "https://github.com/angular/angular-seed", "license": "MIT", "devDependencies": { "bower": "^1.7.7", "http-server": "^0.9.0", "jasmine-core": "^2.4.1", "karma": "^0.13.22", "karma-chrome-launcher": "^0.2.3", "karma-firefox-launcher": "^0.1.7", "karma-jasmine": "^0.3.8", "karma-junit-reporter": "^0.4.1", "protractor": "^3.2.2" }, "scripts": { "postinstall": "bower install",

"prestart": "npm install",
"start": "http-server -a localhost -p 8000 -c-1 ./app",

"pretest": "npm install",
"test": "karma start karma.conf.js",
"test-single-run": "karma start karma.conf.js --single-run",

"preupdate-webdriver": "npm install",
"update-webdriver": "webdriver-manager update",

"preprotractor": "npm run update-webdriver",
"protractor": "protractor e2e-tests/protractor.conf.js",

"update-index-async": "node -e \"var fs=require('fs'),indexFile='app/index-async.html',loaderFile='app/bower_components/angular-loader/angular-loader.min.js',loaderText=fs.readFileSync(loaderFile,'utf-8').split(/sourceMappingURL=angular-loader.min.js.map/).join('sourceMappingURL=bower_components/angular-loader/angular-loader.min.js.map'),indexText=fs.readFileSync(indexFile,'utf-8').split(/\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/).join('//@@NG_LOADER_START@@\\n'+loaderText+'    //@@NG_LOADER_END@@');fs.writeFileSync(indexFile,indexText);\""

} }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/myfunc/chatServer/issues/1#issuecomment-227135680, or mute the thread https://github.com/notifications/unsubscribe/ASZpo4AS_0vYxp6dv8CjrZkTT23Q2AqJks5qNo-MgaJpZM4I5ln4 .