balderdashy / sails

Realtime MVC Framework for Node.js
https://sailsjs.com
MIT License
22.84k stars 1.95k forks source link

Is there any way to install sails locally with no frontend depedencies at all? #3981

Closed pantsel closed 7 years ago

pantsel commented 7 years ago

Sails version:0.12.12-1 Node version:v6.9.1 NPM version:3.10.8 Operating system:Win7 Professional


I'm aware of the

sails generate app --no-frontend

but here's the thing:

When running npm install inside the project folder, it ends up installing all frontend dependencies like gulp and ejs as well.

So I was wondering if there is anyway to skip all frontend deps installation when running npm install .

sailsbot commented 7 years ago

Hi @pantsel! It looks like you may have removed some required elements from the initial comment template, without which I can't verify that this post meets our contribution guidelines. To re-open this issue, please copy the template from here, paste it at the beginning of your initial comment, and follow the instructions in the text. Then post a new comment (e.g. "ok, fixed!") so that I know to go back and check.

Sorry to be a hassle, but following these instructions ensures that we can help you in the best way possible and keep the Sails project running smoothly.

*If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact inquiries@sailsjs.com

sailsbot commented 7 years ago

Hi @pantsel! It looks like you may have removed some required elements from the initial comment template, without which I can't verify that this post meets our contribution guidelines. To re-open this issue, please copy the template from here, paste it at the beginning of your initial comment, and follow the instructions in the text. Then post a new comment (e.g. "ok, fixed!") so that I know to go back and check.

Sorry to be a hassle, but following these instructions ensures that we can help you in the best way possible and keep the Sails project running smoothly.

*If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact inquiries@sailsjs.com

sailsbot commented 7 years ago

Hi @pantsel! It looks like you may have removed some required elements from the initial comment template, without which I can't verify that this post meets our contribution guidelines. To re-open this issue, please copy the template from here, paste it at the beginning of your initial comment, and follow the instructions in the text. Then post a new comment (e.g. "ok, fixed!") so that I know to go back and check.

Sorry to be a hassle, but following these instructions ensures that we can help you in the best way possible and keep the Sails project running smoothly.

*If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact inquiries@sailsjs.com

pantsel commented 7 years ago

ok, fixed!

sailsbot commented 7 years ago

Hi @pantsel! It looks like you may have removed some required elements from the initial comment template, without which I can't verify that this post meets our contribution guidelines. To re-open this issue, please copy the template from here, paste it at the beginning of your initial comment, and follow the instructions in the text. Then post a new comment (e.g. "ok, fixed!") so that I know to go back and check.

Sorry to be a hassle, but following these instructions ensures that we can help you in the best way possible and keep the Sails project running smoothly.

*If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact inquiries@sailsjs.com

pantsel commented 7 years ago

ok, fixed!

sailsbot commented 7 years ago

Sorry to be a hassle, but it looks like your issue is still missing some required info. Please double-check your initial comment and try again.

*If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact inquiries@sailsjs.com

mikermcneil commented 7 years ago

Hey @pantsel - if you're not using the Grunt plugins in your app, you can remove them from "dependencies" in your package.json file. That'll cause them not to be installed automatically when you run npm install.


For future reference, this has been improved a bit in the upcoming release of Sails. In Sails v1, the generated package.json file when you run sails new foo --no-frontend automatically excludes Grunt plugin dependencies (it also takes advantage of the new support for federated hooks to exclude the grunt hook from your app's dependencies altogether).

For example:

image

For more background on the exact differences, see https://github.com/balderdashy/sails-generate/blob/b72c152b54fb422ed3ca8dd76f552b29d1cfc5cc/lib/core-generators/new/get-package-json-data.js#L104-L121

pantsel commented 7 years ago

Thanks for the reply @mikermcneil ,

Correct me if I'm wrong.

When I run sails generate app --no-frontend I get this packacge.json :

{
  "name": "nofront",
  "private": true,
  "version": "0.0.0",
  "description": "a Sails application",
  "keywords": [],
  "dependencies": {
    "include-all": "^1.0.0",
    "rc": "1.0.1",
    "sails": "~0.12.11",
    "sails-disk": "~0.10.9"
  },
  "scripts": {
    "debug": "node debug app.js",
    "start": "node app.js"
  },
  "main": "app.js",
  "repository": {
    "type": "git",
    "url": "git://github.com/anonymous node/sails user/nofront.git"
  },
  "author": "anonymous node/sails user",
  "license": ""
}

As you can see no grunt or other frontend dependencies are listed and my node_modules directory is clean with only the required backend depedencies installed.

Now, if i delete the node_modules folder and run npm install, the created node_modules directory is filled with all frontend depedencies even though none of them is listed in my package.json so, i presume that those installations are required internally by sails.

Why not stick with sails generate app --no-frontend ?

That is cool for generating a new app but it cannot be used for deployment.

mikermcneil commented 7 years ago

Now, if i delete the node_modules folder and run npm install, the created node_modules directory is filled with all frontend depedencies even though none of them is listed in my package.json so, i presume that those installations are required internally by sails.

Hmm... any time that's happened to me, it's been because I was in a different folder than I thought I was. If npm is installing dependencies that aren't in your package.json file when you're in the direct parent folder of that package.json, then I'd hazard something more sinister is going on. (Just a guess, but maybe check for stray aliases in your ~/.profile file?)

pantsel commented 7 years ago

The issue occurs on multiple machines whether they run linux or windows and despite of a clean system image installation.

The package.json of the sails module that gets installed in the node_modules dir is as follows :

{
  "_args": [
    [
      "sails@~0.12.11",
      "D:\\gitlab_projects\\nofront"
    ]
  ],
  "_from": "sails@>=0.12.11 <0.13.0",
  "_id": "sails@0.12.11",
  "_inCache": true,
  "_installable": true,
  "_location": "/sails",
  "_nodeVersion": "4.3.0",
  "_npmOperationalInternal": {
    "host": "packages-12-west.internal.npmjs.com",
    "tmp": "tmp/sails-0.12.11.tgz_1479947860007_0.7122935622464865"
  },
  "_npmUser": {
    "email": "michael.r.mcneil@gmail.com",
    "name": "mikermcneil"
  },
  "_npmVersion": "2.14.12",
  "_phantomChildren": {
    "coffee-script": "1.10.0",
    "dateformat": "1.0.12",
    "eventemitter2": "0.4.14",
    "exit": "0.1.2",
    "findup-sync": "0.3.0",
    "fs.realpath": "1.0.0",
    "grunt-cli": "1.2.0",
    "grunt-known-options": "1.1.0",
    "grunt-legacy-log": "1.0.0",
    "grunt-legacy-util": "1.0.0",
    "inflight": "1.0.6",
    "inherits": "2.0.3",
    "js-yaml": "3.5.5",
    "minimatch": "3.0.3",
    "nopt": "3.0.6",
    "once": "1.4.0",
    "path-is-absolute": "1.0.1",
    "rimraf": "2.2.8"
  },
  "_requested": {
    "name": "sails",
    "raw": "sails@~0.12.11",
    "rawSpec": "~0.12.11",
    "scope": null,
    "spec": ">=0.12.11 <0.13.0",
    "type": "range"
  },
  "_requiredBy": [
    "/"
  ],
  "_resolved": "https://registry.npmjs.org/sails/-/sails-0.12.11.tgz",
  "_shasum": "e22012a8dffe81db68e80523dc782799507f1235",
  "_shrinkwrap": null,
  "_spec": "sails@~0.12.11",
  "_where": "D:\\gitlab_projects\\nofront",
  "author": {
    "email": "@mikermcneil",
    "name": "Mike McNeil"
  },
  "bin": {
    "sails": "./bin/sails.js"
  },
  "bugs": {
    "url": "http://github.com/balderdashy/sails/issues"
  },
  "dependencies": {
    "@sailshq/lodash": "^3.10.2",
    "anchor": "~0.10.5",
    "async": "1.5.0",
    "captains-log": "1.0.0",
    "chalk": "1.1.3",
    "commander": "2.9.0",
    "compression": "1.6.2",
    "connect": "3.4.1",
    "connect-flash": "0.1.1",
    "consolidate": "0.14.1",
    "cookie": "0.1.2",
    "cookie-parser": "1.3.5",
    "cookie-signature": "1.0.6",
    "csurf": "1.9.0",
    "ejs": "2.3.4",
    "ejs-locals": "1.0.2",
    "express": "3.21.2",
    "express-handlebars": "3.0.0",
    "express-session": "1.14.2",
    "flaverr": "^1.0.0",
    "glob": "5.0.15",
    "grunt": "1.0.1",
    "grunt-cli": "1.2.0",
    "grunt-contrib-clean": "1.0.0",
    "grunt-contrib-coffee": "1.0.0",
    "grunt-contrib-concat": "1.0.1",
    "grunt-contrib-copy": "1.0.0",
    "grunt-contrib-cssmin": "1.0.1",
    "grunt-contrib-jst": "1.0.0",
    "grunt-contrib-less": "1.3.0",
    "grunt-contrib-uglify": "1.0.1",
    "grunt-contrib-watch": "1.0.0",
    "grunt-sails-linker": "~0.10.1",
    "grunt-sync": "0.5.2",
    "i18n": "0.8.1",
    "include-all": "^1.0.0",
    "merge-defaults": "~0.2.1",
    "method-override": "2.3.5",
    "mock-req": "0.2.0",
    "mock-res": "0.3.0",
    "parseurl": "1.3.1",
    "path-to-regexp": "1.5.3",
    "pluralize": "1.2.1",
    "prompt": "0.2.14",
    "rc": "1.0.1",
    "reportback": "~0.1.9",
    "rttc": "9.3.3",
    "sails-disk": "~0.10.9",
    "sails-generate": "~0.13.0",
    "sails-hook-orm": "~1.0.6",
    "sails-hook-sockets": "^0.13.9",
    "sails-stringfile": "~0.3.2",
    "sails-util": "~0.11.0",
    "semver": "5.1.0",
    "serve-favicon": "2.3.0",
    "serve-static": "1.10.2",
    "skipper": "~0.6.0",
    "uid-safe": "1.1.0",
    "walk": "2.3.9",
    "waterline": "~0.11.0"
  },
  "description": "API-driven framework for building realtime apps, using MVC conventions (based on Express and Socket.io)",
  "devDependencies": {
    "benchmark": "1.0.0",
    "checksum": "0.1.1",
    "coffee-script": "1.9.1",
    "expect.js": "0.3.1",
    "fs-extra": "0.30.0",
    "istanbul": "0.4.1",
    "machinepack-fs": "^8.0.2",
    "machinepack-process": "^2.0.2",
    "mocha": "3.0.0",
    "portfinder": "0.4.0",
    "request": "2.68.0",
    "root-require": "0.3.1",
    "should": "5.2.0",
    "socket.io-client": "1.4.6",
    "supertest": "1.1.0",
    "tmp": "0.0.30"
  },
  "directories": {
    "lib": "lib"
  },
  "dist": {
    "shasum": "e22012a8dffe81db68e80523dc782799507f1235",
    "tarball": "https://registry.npmjs.org/sails/-/sails-0.12.11.tgz"
  },
  "engines": {
    "node": ">= 0.10.0",
    "npm": ">= 1.4.0"
  },
  "gitHead": "0ce0d867cf062b0ad4c34238d8cd0c49f5cafb31",
  "homepage": "http://sailsjs.org",
  "keywords": [
    "mvc",
    "web-framework",
    "express",
    "sailsjs",
    "sails.js",
    "REST",
    "API",
    "orm",
    "socket.io"
  ],
  "license": "MIT",
  "main": "./lib/index.js",
  "maintainers": [
    {
      "email": "mike@balderdashdesign.com",
      "name": "balderdashy"
    },
    {
      "email": "particlebanana@gmail.com",
      "name": "particlebanana"
    },
    {
      "email": "scott@balderdash.co",
      "name": "sgress454"
    },
    {
      "email": "michael.r.mcneil@gmail.com",
      "name": "mikermcneil"
    }
  ],
  "name": "sails",
  "optionalDependencies": {},
  "readme": "ERROR: No README data found!",
  "repository": {
    "type": "git",
    "url": "git://github.com/balderdashy/sails.git"
  },
  "scripts": {
    "preinstall": "node ./lib/preinstall_npmcheck.js",
    "prepublish": "npm prune",
    "test": "mocha -b"
  },
  "version": "0.12.11"
}

As you can see all frontend stuff are listed as dependencies, so they end up getting installed anyway.

mikermcneil commented 7 years ago

@pantsel ah I'm sorry, you're talking about the dependencies of Sails itself-- now I follow you. NPM 3+ still throws me for a loop sometimes-- I'm still used to the old way (and prefer it honestly :/ ).

So anyway, yes, those are dependencies of Sails core in version 0.12. So if you're using NPM >v2, they'll appear as direct children of your node_modules folder. In Sails version 1.0, they aren't dependencies of Sails core anymore (they're deps of sails-hook-grunt). So if you generate an app the way you mentioned above, you won't see these dependencies in your project, because you won't have the sails-hook-grunt dependency.

Hope that helps, and again, apologies for the confusion!

pantsel commented 7 years ago

@mikermcneil I see.

So the issue is resolved in 1+ version.

It was a pain not be able to use this awesome project for pure APIs only because it added about 40MB of dependencies which where actually useless for a strict API implementation.

Thanks for your time.

StoneRen commented 7 years ago

same as @pantsel --no-frontend & want to use sails as a pre backend service.

1 2