angular-fullstack / generator-angular-fullstack

Yeoman generator for an Angular app with an Express server
https://awk34.gitbook.io/generator-angular-fullstack
6.13k stars 1.24k forks source link

Latest version (4.1.0) not starting, multiple JS errors #2277

Open MariusStuparu opened 8 years ago

MariusStuparu commented 8 years ago

After updating generator-angular-fullstack to the latest version, 4.1.0, a fresh app will not start because of multiple errors.

Gulp errors

\client\components\auth\auth.service.js
119:19  error    '_' is not defined

Browser console errors:

Uncaught Error: [$injector:modulerr] Failed to instantiate module ng due to:
Error: [$injector:strictdi] function($provide) is not using explicit annotation and cannot be invoked in strict mode
at http://localhost:3000/vendor.bundle.js:194:13
    at Function.annotate [as $$annotate] (http://localhost:3000/vendor.bundle.js:4078:18)
...

Environment: Node 5.9.0, Npm 3.7.3, Gulp 3.9.1

.yo-rc.json has this:

{
  "generator-angular-fullstack": {
    "generatorVersion": "4.1.0",
    "endpointDirectory": "server/api/",
    "insertRoutes": true,
    "registerRoutesFile": "server/routes.js",
    "routesNeedle": "// Insert routes below",
    "routesBase": "/api/",
    "pluralizeRoutes": true,
    "insertSockets": true,
    "registerSocketsFile": "server/config/socketio.js",
    "socketsNeedle": "// Insert sockets below",
    "insertModels": true,
    "registerModelsFile": "server/sqldb/index.js",
    "modelsNeedle": "// Insert models below",
    "filters": {
      "js": true,
      "babel": true,
      "flow": true,
      "pug": true,
      "sass": true,
      "uirouter": true,
      "bootstrap": true,
      "uibootstrap": true,
      "auth": true,
      "models": true,
      "mongooseModels": true,
      "mongoose": true,
      "oauth": true,
      "facebookAuth": true,
      "mocha": true,
      "jasmine": false,
      "should": false,
      "expect": true
    }
  },
  "generator-ng-component": {
    "routeDirectory": "client/app/",
    "directiveDirectory": "client/app/",
    "componentDirectory": "client/app/components/",
    "filterDirectory": "client/app/",
    "serviceDirectory": "client/app/",
    "basePath": "client",
    "moduleName": "",
    "modulePrompt": true,
    "filters": [
      "uirouter",
      "mocha",
      "expect",
      "uirouter",
      "es6",
      "webpack"
    ],
    "extensions": [
      "babel",
      "js",
      "pug",
      "scss"
    ],
    "directiveSimpleTemplates": "",
    "directiveComplexTemplates": "",
    "filterTemplates": "",
    "serviceTemplates": "",
    "factoryTemplates": "",
    "controllerTemplates": "",
    "componentTemplates": "",
    "decoratorTemplates": "",
    "providerTemplates": "",
    "routeTemplates": ""
  }
}
Awk34 commented 8 years ago

Do you know where that $provide injection is coming from?

MariusStuparu commented 8 years ago

This is right after yo angular-fullstack:app, so I haven't changed anything in the generated code.

Awk34 commented 8 years ago

I copied your .yo-rc.json config and scaffolded a new app with 4.1.0, and it loaded up fine. Can you provide more details? Try wiping your node_modules clean, clearing the npm cache, and then re-installing the npm dependencies.

MariusStuparu commented 7 years ago

After running a npm remove -g generator-angular-fullstack and npm cache clean, I did a re-install, created a new project with all defaults except selecting Pug instead of HTML, then ran gulp serve. This time the app started, but I still get some errors when starting, and the browser page is opened too early. I get a "page not available" first, and only later, if I do a reload, I get the page.

Below, the entire console output (with some folders obfuscated):

$ gulp serve
[11:59:43] Requiring external module babel-register
(node) crypto.createCredentials is deprecated. Use tls.createSecureContext instead.

(node) crypto.Credentials is deprecated. Use tls.createSecureContext instead.
[11:59:49] Using gulpfile [...]\gulpfile.babel.js
[11:59:49] Starting 'serve'...
[11:59:49] Starting 'clean:tmp'...
[11:59:49] Starting 'lint:scripts'...
[11:59:49] Starting 'lint:scripts:client'...
[11:59:49] Starting 'lint:scripts:server'...
[11:59:49] Starting 'inject'...
[11:59:49] Starting 'inject:scss'...
[11:59:50] Starting 'copy:fonts:dev'...
[11:59:50] Starting 'env:all'...
[11:59:50] Finished 'env:all' after 45 ms
[11:59:50] Finished 'clean:tmp' after 179 ms
[11:59:51] gulp-inject 4 files into app.scss.
[11:59:51] Finished 'inject:scss' after 1.7 s
[11:59:51] Finished 'inject' after 1.7 s
[11:59:53]
[...]\server\index.js
  4:11  warning  Unexpected use of process.env  no-process-env
  4:34  warning  Unexpected use of process.env  no-process-env

[...]\server\config\express.js
  66:25  warning  Unexpected use of process.env  no-process-env

[...]\server\api\thing\thing.controller.js
   29:7  warning  Avoid using Function.prototype.apply, instead use Reflect.apply
   prefer-reflect
   91:5  warning  Avoid using the delete keyword, instead use Reflect.deleteProperty  prefer-reflect
  102:5  warning  Avoid using the delete keyword, instead use Reflect.deleteProperty  prefer-reflect

[...]\server\api\user\user.model.js
  162:15  warning  Use the rest parameters instead of 'arguments'  prefer-rest-params
  163:18  warning  Use the rest parameters instead of 'arguments'  prefer-rest-params
  165:22  warning  Use the rest parameters instead of 'arguments'  prefer-rest-params
  166:18  warning  Use the rest parameters instead of 'arguments'  prefer-rest-params
  206:14  warning  Unexpected sync method: 'pbkdf2Sync'            no-sync

✖ 11 problems (0 errors, 11 warnings)

[11:59:53] Finished 'lint:scripts:server' after 3.45 s
[11:59:53] Finished 'copy:fonts:dev' after 3.41 s
[11:59:53]
[...]\client\components\auth\auth.service.js
  118:19  error    '_' is not defined
 no-undef
  148:20  error    '_' is not defined
 no-undef
  161:16  error    '_' is not defined
 no-undef
  174:29  error    '_' is not defined
 no-undef
  188:22  error    '_' is not defined
 no-undef
  199:14  warning  Avoid using Function.prototype.apply, instead use Reflect.apply  prefer-reflect
  199:14  warning  use the spread operator instead of the '.apply()'
 prefer-spread
  199:39  warning  Avoid using Function.prototype.apply, instead use Reflect.apply  prefer-reflect
  199:66  warning  Use the rest parameters instead of 'arguments'
 prefer-rest-params
  208:14  warning  Unexpected sync method: 'hasRoleSync'
 no-sync

[...]\client\components\modal\modal.service.js
  42:22  warning  Avoid using Function.prototype.call, instead use Reflect.apply
prefer-reflect
  42:49  warning  Use the rest parameters instead of 'arguments'
prefer-rest-params
  68:13  warning  Avoid using Function.prototype.apply, instead use Reflect.apply
prefer-reflect

[...]\client\components\util\util.service.js
  59:99  warning  '===' should be placed at the beginning of the line  operator-linebreak

✖ 14 problems (5 errors, 9 warnings)

[11:59:53] Finished 'lint:scripts:client' after 3.65 s
[11:59:53] Finished 'lint:scripts' after 3.65 s
[11:59:53] Starting 'start:server'...
[11:59:53] Finished 'start:server' after 11 ms
[11:59:53] Starting 'start:client'...
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: [...]\server/**/*
[nodemon] starting `node server`
(node) crypto.createCredentials is deprecated. Use tls.createSecureContext instead.

(node) crypto.Credentials is deprecated. Use tls.createSecureContext instead.
Express server listening on 9000, in development mode
[11:59:57] Finished 'start:client' after 4.38 s
[11:59:57] Starting 'watch'...
[11:59:58] Finished 'watch' after 117 ms
[11:59:58] Finished 'serve' after 8.17 s
Error: ENOENT: no such file or directory, stat '[...]\client\index.html'
    at Error (native)
Error: ENOENT: no such file or directory, stat '[...]\client\index.html'
    at Error (native)
Error: ENOENT: no such file or directory, stat '[...]\client\index.html'
    at Error (native)
Error: ENOENT: no such file or directory, stat '[...]\client\index.html'
    at Error (native)
Error: ENOENT: no such file or directory, stat '[...]\client\index.html'
    at Error (native)
Error: ENOENT: no such file or directory, stat '[...]\client\index.html'
    at Error (native)
Error: ENOENT: no such file or directory, stat '[...]\client\index.html'
    at Error (native)
Error: ENOENT: no such file or directory, stat '[...]\client\index.html'
    at Error (native)
Error: ENOENT: no such file or directory, stat '[...]\client\index.html'
    at Error (native)
Error: ENOENT: no such file or directory, stat '[...]\client\index.html'
    at Error (native)
Error: ENOENT: no such file or directory, stat '[...]\client\index.html'
    at Error (native)
finished populating users
GET / 404 1335.639 ms - 133
GET / 404 11.646 ms - 133
GET / 404 284.960 ms - 133
GET / 404 284.647 ms - 133
GET / 404 1335.499 ms - 133
GET / 404 1335.526 ms - 133
GET / 404 1351.077 ms - 133
GET / 404 1351.001 ms - 133
GET / 404 1351.106 ms - 133
GET / 404 4.688 ms - 133
GET / 404 4.116 ms - 133
[BS] Proxying: http://localhost:9000
[BS] Access URLs:
 --------------------------------------
       Local: http://localhost:3000
    External: http://10.171.71.246:3000
 --------------------------------------
          UI: http://localhost:3002
 UI External: http://10.171.71.246:3002
 --------------------------------------
webpack: wait until bundle finished: /
webpack done hook
Hash: d23c509d9d5bc1fa6731
Version: webpack 1.13.2
Time: 8626ms
                  Asset     Size  Chunks             Chunk Names
          app.bundle.js   405 kB       0  [emitted]  app
    polyfills.bundle.js   206 kB       1  [emitted]  polyfills
       vendor.bundle.js  2.48 MB       2  [emitted]  vendor
      app.bundle.js.map   540 kB       0  [emitted]  app
polyfills.bundle.js.map   270 kB       1  [emitted]  polyfills
   vendor.bundle.js.map  2.89 MB       2  [emitted]  vendor
   ../client/index.html  1.39 kB          [emitted]
Child html-webpack-plugin for "..\client\index.html":
                   Asset    Size  Chunks       Chunk Names
    ../client/index.html  555 kB       0
webpack: bundle is now VALID.
webpack: bundle is now INVALID.
webpack: wait until bundle finished: /vendor.bundle.js
webpack: wait until bundle finished: /polyfills.bundle.js
webpack: wait until bundle finished: /app.bundle.js
webpack done hook
Hash: d23c509d9d5bc1fa6731
Version: webpack 1.13.2
Time: 629ms
                  Asset     Size  Chunks       Chunk Names
          app.bundle.js   405 kB       0       app
    polyfills.bundle.js   206 kB       1       polyfills
       vendor.bundle.js  2.48 MB       2       vendor
      app.bundle.js.map   540 kB       0       app
polyfills.bundle.js.map   270 kB       1       polyfills
   vendor.bundle.js.map  2.89 MB       2       vendor
Child html-webpack-plugin for "..\client\index.html":
                   Asset    Size  Chunks       Chunk Names
    ../client/index.html  555 kB       0
webpack: bundle is now VALID.
SocketIO / [127.0.0.1:54850] CONNECTED

At this point, the app is available.

Awk34 commented 7 years ago

The first errors are just linting errors. Then, the Error: ENOENT: no such file or directory, stat '[...]\client\index.html' just shows up until Webpack has created the index.html file from the template. So you should be good to go.