angular-fullstack / generator-angular-fullstack

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

sequelize errors during 'grunt serve' on current canary version #1477

Closed jeffbuhrt closed 8 years ago

jeffbuhrt commented 8 years ago

I updated to node-4.2.3, changed grunt-node-inspector from 0.2.0 to 0.4.0 per #1357 (https://github.com/angular-fullstack/generator-angular-fullstack/issues/1357#issuecomment-163457461) (to get past the still current NaN compile issues), then tried to run using sequelize on a freshly generated project (connected to Postgres) and get:

Running "express:dev" (express) task Starting background Express server Debugger listening on port 5858 module.js:339 throw err; ^

Error: Cannot find module './$.export' at Function.Module._resolveFilename (module.js:337:15) at Function.Module._load (module.js:287:25) at Module.require (module.js:366:17) at require (module.js:385:17) at Object. (/home/jbuhrt/GenElder/node_modules/babel-core/node_modules/core-js/modules/es5.js:3:25) at Module._compile (module.js:435:26) at Object.Module._extensions..js (module.js:442:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:311:12) at Module.require (module.js:366:17) Stopping Express server

Note a mongo generated version with the all options set the same way works fine.

kingcody commented 8 years ago

@jeffbuhrt can you post your .yo-rc.json file?

jeffbuhrt commented 8 years ago

Thanks Cody (@kingcody).

$ cat .yo-rc.json { "generator-angular-fullstack": { "generatorVersion": "3.0.0-rc8", "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, "jade": true, "less": true, "uirouter": true, "bootstrap": true, "uibootstrap": true, "socketio": true, "auth": true, "models": true, "sequelizeModels": true, "sequelize": true, "oauth": true, "googleAuth": true, "facebookAuth": true, "twitterAuth": true, "grunt": true, "jasmine": true, "mocha": false, "should": false, "expect": false } }, "generator-ng-component": { "routeDirectory": "client/app/", "directiveDirectory": "client/app/", "filterDirectory": "client/app/", "serviceDirectory": "client/app/", "basePath": "client", "moduleName": "", "filters": [ "uirouter", "jasmine", "uirouter" ], "extensions": [ "js", "jade", "less" ], "directiveSimpleTemplates": "", "directiveComplexTemplates": "", "filterTemplates": "", "serviceTemplates": "", "factoryTemplates": "", "controllerTemplates": "", "decoratorTemplates": "", "providerTemplates": "", "routeTemplates": "" } }

kingcody commented 8 years ago

Well, I just tried with a fresh install on the master branch (3.0.2), no problems. I did get a bunch of sequelize warnings but no errors.

node v4.2.3

jeffbuhrt commented 8 years ago

So canary is broken for sequelize.

kingcody commented 8 years ago

Actually, it looks like canary and master are in sync atm.

jeffbuhrt commented 8 years ago

Talk about finicky... It isn't easy to get the right sequence of what to install when. It would seem a dependency sequence could be defined.

Either way sequelize seems broken.

Anyhow, maybe these breadcrumbs will help someone on the sequence to use:

tar xvzf node-v4.2.3-linux-x64.tar.gz npm install yo -g npm grunt-cli bower phantomjs sinon chai less jade pg sequelize pg pg-hstore less

git clone https://github.com/angular-fullstack/generator-angular-fullstack.git cd generator-angular-fullstack npm link ...

home/jbuhrt/AngularJS/node-v4.2.3-linux-x64/lib/node_modules/generator-angular-fullstack -> /home/jbuhrt/AngularJS/generator-angular-fullstack

cd mkdir xx cd xx yo angular-fullstack xx

You're using the Angular Full-Stack Generator, version 3.0.0-rc8 ... ^C (hung on: loadDep:repeat-string → n) jove package.json "grunt-node-inspector": "^0.4.0",

npm install -g node-inspector chai sinon sinon-chai phantomjs npm install -g pg phantomjs sinon npm install bower install (which fails to compile sqlite3) make: Entering directory '/home/jbuhrt/AngularJS/node-v4.2.3-linux-x64/lib/node_modules/gen-elder/node_modules/sqlite3/build' ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3081101/sqlite3.c TOUCH Release/obj.target/deps/action_before_build.stamp CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3081101/sqlite3.o AR(target) Release/obj.target/deps/sqlite3.a COPY Release/sqlite3.a CXX(target) Release/obj.target/node_sqlite3/src/database.o In file included from ../src/database.h:11:0, from ../src/database.cc:5: ../node_modules/nan/nan.h:261:25: error: redefinition of ‘template v8::Local _NanEnsureLocal(v8::Local)’ NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {

Anyhow, now just no server/sqldb/Thing.* files are created. I know at one point when I was using the older version I had tables created in Postgres.

jeffbuhrt commented 8 years ago

It seems staring with a clean node-v4.2.3-linux-x64.tar.gz then just following the default instructions on https://github.com/angular-fullstack/generator-angular-fullstack/tree/master

To just use the default of mongo I still had to: dnf install krb5-devel npm install ultron options and fix "grunt-node-inspector": "^0.4.0"

I was then finally able to run the mongo demo. I can't make it create the sqldb files.

Awk34 commented 8 years ago

@jeffbuhrt the Error: Cannot find module './$.export' error is the reason that I switched us from using Travis-CI to Codeship. Pretty much all builds started failing on Travis, but when I switched to Codeship all cleared up. I can only assume it's an OS or build-tool issue.

jeffbuhrt commented 8 years ago

I went back to this again. [What a pain.]

An older generator did create a seed.js that contained: import Thing from '../api/thing/thing.model'; import User from '../api/user/user.model'; and was able to load to Postgres.

Every time I try to run the generator I see: 3.0.0-rc8 not 3.2.0. I haven't figured out the npm/node magic to be able to use the newer 3.2.0 to see if the sequelize works again and if needing to change grunt-node-inspector from 0.2.0 to 0.4.0 is fixed.

Thanks,

-Jeff

Awk34 commented 8 years ago

You should be able to just npm install -g generator-angular-fullstack@3.2.0

jeffbuhrt commented 8 years ago

@Awk34 I have reworked this order multiple times. Note this is 4.2.8-300.fc23.x86_64 (Fedora 23)

rm -rf node-v4.2.4-linux-x64/ tar xvzf node-v4.2.3-linux-x64.tar.gz cd node-v4.2.4-linux-x64/

Note do NOT install 'npm' at the same time as yo, etc. it will blow away the npm/lib directory

npm install -g npm npm install -g yo grunt-cli bower npm install -g generator-angular-fullstack@3.2.0

$ yo angular-fullstack x ... You're using the Angular Full-Stack Generator, version 3.0.0-rc8

I had also tried Cody's linking ideas and the cases I don't have npm errors I still see 3.0.0-rc8 In node-v4.2.4-linux-x64/lib/node_modules/generator-angular-fullstack/package.json I see "generator-angular-fullstack@3.2.0"

The node/npm with the 3.2.0 above is the version I am using: $ hash | grep node 78 /home/jbuhrt/AngularJS/node-v4.2.4-linux-x64/bin/npm 1 /home/jbuhrt/AngularJS/node-v4.2.4-linux-x64/bin/node 23 /home/jbuhrt/AngularJS/node-v4.2.4-linux-x64/bin/yo 12 /home/jbuhrt/AngularJS/node-v4.2.4-linux-x64/bin/grunt 1 /home/jbuhrt/AngularJS/node-v4.2.4-linux-x64/bin/bower

Ideas?

Awk34 commented 8 years ago

If you have downloaded a copy of the generator and npm linked it manually, you should npm unlink it to use the one downloaded from npm.

jeffbuhrt commented 8 years ago

@Awk34 still no joy...

node-v4.2.4-linux-x64]$ npm unlink -g generator-angular-fullstack

node-v4.2.4-linux-x64]$ npm install -g generator-angular-fullstack@3.2.0 WARN engine generator-angular-fullstack@3.2.0: wanted: {"node":"^4.2.3","npm":"^2.14.7"} (current: {"node":"4.2.4","npm":"3.5.2"})

spawn-sync@1.0.15 postinstall /home/jbuhrt/AngularJS/node-v4.2.4-linux-x64/lib/node_modules/generator-angular-fullstack/node_modules/spawn-sync node postinstall

/home/jbuhrt/AngularJS/node-v4.2.4-linux-x64/lib └─┬ generator-angular-fullstack@3.2.0 ├─┬ babel-core@5.8.34 ... (no errors)

x$ yo angular-fullstack x

################################################################

NOTE: You are using a pre-release version of

generator-angular-fullstack. For a more stable version, run

npm install -g generator-angular-fullstack@^2.0.0

################################################################ You're using the Angular Full-Stack Generator, version 3.0.0-rc8 ...

Debugging using http://yeoman.io/authoring/debugging.html doesn't seem to show anything helpful, and --trace is a huge amount of node internals [I think I would rather debug Java code.]

Thanks again.

jeffbuhrt commented 8 years ago

(oops, forgot to make sure nothing was markdown)

Awk34 commented 8 years ago

try a npm r generator-angular-fullstack -g

kingcody commented 8 years ago

I think I would rather debug Java code

For the past 3 months I've been head down in Groovy (grails) and I personally would take a Node dump over java's "bash output overflowing" traces any day.

jeffbuhrt commented 8 years ago

@Awk34 same thing [I have reinstalled a clean node multiple times and I have deleted the git fullstack directory a while ago.]

kingcody commented 8 years ago

@jeffbuhrt which node?

jeffbuhrt commented 8 years ago

Yeah!

1) The problem was a copy in: /usr/lib/node_modules/generator-angular-fullstack/package.json from Oct 22nd, 2015 ("_id": "generator-angular-fullstack@3.0.0-rc8") Is there a way to ask yo what path it is using to make this simpler to debug for other people?

2) Using postgres under sequelize is back to where it was a while ago at least. It runs, with a minor exception.

Anyone following this thread note you need to run 'grunt serve' twice to make the demo run. The first runs creates and loads the tables but the browser is unable to connect to localhost:9000, the 2nd run is fine.

I assume the error has to do with the two promise 'warnings', sample below:

Executing (default): INSERT INTO "Things" ("_id","name","info","createdAt","updatedAt") VALUES (DEFAULT,'Development Tools','Integration with popular tools such as Bower, Grunt, Babel, Karma, Mocha, JSHint, Node Inspector, Livereload, Protractor, Jade, Stylus, Sass, and Less.','2016-01-07 03:23:31.144 +00:00','2016-01-07 03:23:31.144 +00:00'),(DEFAULT,'Server and Client integration','Built with a powerful and fun stack: MongoDB, Express, AngularJS, and Node.','2016-01-07 03:23:31.144 +00:00','2016-01-07 03:23:31.144 +00:00'),(DEFAULT,'Smart Build System','Build system ignores spec files, allowing you to keep tests alongside code. Automatic injection of scripts and styles into your index.html','2016-01-07 03:23:31.144 +00:00','2016-01-07 03:23:31.144 +00:00'),(DEFAULT,'Modular Structure','Best practice client and server structures allow for more code reusability and maximum scalability','2016-01-07 03:23:31.144 +00:00','2016-01-07 03:23:31.144 +00:00'),(DEFAULT,'Optimized Build','Build process packs up your templates as a single JavaScript payload, minifies your scripts/css/images, and rewrites asset names for caching.','2016-01-07 03:23:31.144 +00:00','2016-01-07 03:23:31.144 +00:00'),(DEFAULT,'Deployment Ready','Easily deploy your app to Heroku or Openshift with the heroku and openshift subgenerators','2016-01-07 03:23:31.144 +00:00','2016-01-07 03:23:31.144 +00:00'); Warning: a promise was created in a handler but was not returned from it at [object Object].Model.bulkCreate (/home/jbuhrt/GenElder/node_modules/sequelize/lib/model.js:2102:21) at /home/jbuhrt/GenElder/server/config/seed.js:49:10 at processImmediate as _immediateCallback From previous event: at Promise.then (/home/jbuhrt/GenElder/node_modules/sequelize/lib/promise.js:21:17) at Object. (/home/jbuhrt/GenElder/server/config/seed.js:48:4) at Module._compile (module.js:435:26) at normalLoader (/home/jbuhrt/GenElder/node_modules/babel-core/lib/api/register/node.js:199:5) at Object.require.extensions.(anonymous function) as .js at Module.load (module.js:356:32) at Function.Module._load (module.js:313:12) at Module.require (module.js:366:17) at require (module.js:385:17) at Object. (/home/jbuhrt/GenElder/server/app.js:22:22) at Module._compile (module.js:435:26) at normalLoader (/home/jbuhrt/GenElder/node_modules/babel-core/lib/api/register/node.js:199:5) at Object.require.extensions.(anonymous function) as .js at Module.load (module.js:356:32) at Function.Module._load (module.js:313:12) at Module.require (module.js:366:17) at require (module.js:385:17) at Object. (/home/jbuhrt/GenElder/server/index.js:12:28) at Module._compile (module.js:435:26) at Object.Module._extensions..js (module.js:442:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:313:12) at Function.Module.runMain (module.js:467:10) at startup (node.js:136:18) at node.js:963:3

kingcody commented 8 years ago

@jeffbuhrt if you want to get rid of that warning (from bluebird lib) apply these changes:

@@ -15,3 +15,3 @@
   .then(() => {
-    Thing.bulkCreate([{
+    return Thing.bulkCreate([{
       name: 'Development Tools',
@@ -48,3 +48,3 @@
   .then(() => {
-    User.bulkCreate([{
+    return User.bulkCreate([{
       provider: 'local',
jeffbuhrt commented 8 years ago

@kingcody adding the return's fix the exception, but it still requires 'grunt serve' a second time the very first time the tables are created. I assume someone should make a pull request for your fix. [Again, this is using sequelize + Postgres for the tables]

1st run: ... -01-07 18:53:54.636 +00:00'); finished populating users Done waiting!

Running "open:server" (open) task

Running "watch" task Waiting... [No port 9000 listening](netstat -an |grep 9000)]

^C

2nd grunt serve ... finished populating users Done waiting!

Running "open:server" (open) task

Running "watch" task Waiting... SocketIO / [127.0.0.1:46858] CONNECTED SocketIO / [127.0.0.1:46864] CONNECTED SocketIO / [127.0.0.1:46866] CONNECTED SocketIO / [127.0.0.1:46868] CONNECTED SocketIO / [127.0.0.1:46866] CONNECTED Executing (default): SELECT "_id", "name", "info", "active", "createdAt", "updatedAt" FROM "Things" AS "Thing"; GET /api/things 200 30.473 ms - -

(demo runs fine)

jeffbuhrt commented 8 years ago

Changes to allow Postgres, etc to run the demo.

-- 1. No model for Thing, otherwise exception

Running "express:dev" (express) task
Starting background Express server
Debugger listening on port 5858
/home/jbuhrt/GenElder/server/config/seed.js:17
Thing.sync().then(function () {
^

TypeError: Cannot read property 'sync' of undefined
at Object.<anonymous> (/home/jbuhrt/GenElder/server/config/seed.js:11:6)
at Module._compile (module.js:435:26)
at normalLoader (/home/jbuhrt/GenElder/node_modules/babel-core/lib/api/register/node.js:199:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/jbuhrt/GenElder/node_modules/babel-core/lib/api/register/node.js:216:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/home/jbuhrt/GenElder/server/app.js:22:22)
at Module._compile (module.js:435:26)
at normalLoader (/home/jbuhrt/GenElder/node_modules/babel-core/lib/api/register/node.js:199:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/jbuhrt/GenElder/node_modules/babel-core/lib/api/register/node.js:216:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/home/jbuhrt/GenElder/server/index.js:12:28)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3
Stopping Express server

Change:

server/sqldb/index.js
16a17
> db.Thing = db.sequelize.import('../api/thing/thing.model');

-- 2. Promise needs return to fix warnings

Running "express:dev" (express) task
Starting background Express server
Debugger listening on port 5858
Warning: a promise was created in a handler but was not returned from it
at [object Object].Model.bulkCreate (/home/jbuhrt/GenElder/node_modules/sequelize/lib/model.js:2102:21)
at /home/jbuhrt/GenElder/server/config/seed.js:16:11
at processImmediate [as _immediateCallback] (timers.js:383:17)
From previous event:
at Promise.then (/home/jbuhrt/GenElder/node_modules/sequelize/lib/promise.js:21:17)
at Object.<anonymous> (/home/jbuhrt/GenElder/server/config/seed.js:15:4)
at Module._compile (module.js:435:26)
at normalLoader (/home/jbuhrt/GenElder/node_modules/babel-core/lib/api/register/node.js:199:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/jbuhrt/GenElder/node_modules/babel-core/lib/api/register/node.js:216:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/home/jbuhrt/GenElder/server/app.js:22:22)
at Module._compile (module.js:435:26)
at normalLoader (/home/jbuhrt/GenElder/node_modules/babel-core/lib/api/register/node.js:199:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/jbuhrt/GenElder/node_modules/babel-core/lib/api/register/node.js:216:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/home/jbuhrt/GenElder/server/index.js:12:28)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3

Warning: a promise was created in a handler but was not returned from it
at [object Object].Model.bulkCreate (/home/jbuhrt/GenElder/node_modules/sequelize/lib/model.js:2102:21)
at /home/jbuhrt/GenElder/server/config/seed.js:49:10
at processImmediate [as _immediateCallback] (timers.js:383:17)
From previous event:
at Promise.then (/home/jbuhrt/GenElder/node_modules/sequelize/lib/promise.js:21:17)
at Object.<anonymous> (/home/jbuhrt/GenElder/server/config/seed.js:48:4)
at Module._compile (module.js:435:26)
at normalLoader (/home/jbuhrt/GenElder/node_modules/babel-core/lib/api/register/node.js:199:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/jbuhrt/GenElder/node_modules/babel-core/lib/api/register/node.js:216:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/home/jbuhrt/GenElder/server/app.js:22:22)
at Module._compile (module.js:435:26)
at normalLoader (/home/jbuhrt/GenElder/node_modules/babel-core/lib/api/register/node.js:199:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/jbuhrt/GenElder/node_modules/babel-core/lib/api/register/node.js:216:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/home/jbuhrt/GenElder/server/index.js:12:28)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3

Change:

server/config/seed.js
16c16
< Thing.bulkCreate([{
---
> return Thing.bulkCreate([{
49c49
< User.bulkCreate([{
---
> return User.bulkCreate([{

-- 3. No server route to see Things [No list of Things seen]

Running "watch" task
Completed in 3.629s at Fri Jan 22 2016 15:41:59 GMT-0500 (EST) - Waiting...
SocketIO / [127.0.0.1:52148] DISCONNECTED
SocketIO / [127.0.0.1:52148] CONNECTED
GET /api/things 404 514.748 ms - -

Change:

server/routes.js
11a12
> app.use('/api/things', require('./api/thing'));

-- 4. Thing list shows, but new Things don't appear until manual page refresh. Change:

server/config/socketio.js
19a20
> require('../api/thing/thing.socket').register(socket);

-- 5. Fix typo Change:

server/config/environment/development.js
11,12d9
<
< // Sequelize connecton opions
---
< // Sequelize connection options

-- 6. Suggest Postgres URI Change:

server/config/environment/development.js
14c11,12
< uri: 'sqlite://',
---
> // uri: 'sqlite://',
> uri: 'postgres://' + process.env.USER + ':@localhost:5432/genelder',
jeffbuhrt commented 8 years ago

@kingcody A 'git commit' returned: [canary ee76b16] fix(app)correct sequelize to run demo #1477 5 files changed, 9 insertions(+), 5 deletions(-)

Now what? [What is required to turn it into a pull request?]

kingcody commented 8 years ago

git push to your fork on github?

jeffbuhrt commented 8 years ago

@kingcody ok, ready to pull. Thanks.