angular / universal

Server-side rendering and Prerendering for Angular
MIT License
4.04k stars 483 forks source link

"Cannot read property 'makeCurrent' of undefined" on ng serve clean CLI install #470

Closed adrw closed 8 years ago

adrw commented 8 years ago

Note: for support questions, please use one of these channels: https://github.com/angular/universal/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports.

Could not start watchman; falling back to NodeWatcher for file system events. Visit http://ember-cli.com/user-guide/#watchman for more info. Cannot read property 'makeCurrent' of undefined TypeError: Cannot read property 'makeCurrent' of undefined at Object.<anonymous> (/Users/andrew/Sites/hello-mobile/node_modules/angular2-universal/dist/node/node.js:7:35) at Module._compile (module.js:413:34) at Object.Module._extensions..js (module.js:422:10) at Module.load (module.js:357:32) at Function.Module._load (module.js:314:12) at Module.require (module.js:367:17) at require (internal/module.js:20:19) at Object.<anonymous> (/Users/andrew/Sites/hello-mobile/node_modules/angular2-universal/dist/node/index.js:5:17) at Module._compile (module.js:413:34) at Object.Module._extensions..js (module.js:422:10) at Module.load (module.js:357:32) at Function.Module._load (module.js:314:12) at Module.require (module.js:367:17) at require (internal/module.js:20:19) at Object.<anonymous> (/Users/andrew/Sites/hello-mobile/node_modules/angular2-broccoli-prerender/dist/prerender.js:8:28) at Module._compile (module.js:413:34)

PatrickJS commented 8 years ago

can you install

"@angular/platform-server": "2.0.0-rc.4",
"css": "^2.2.1",
"parse5": "^1.5.0"
adrw commented 8 years ago

I get these errors when I add those to the package.json and do npm install

npm WARN @angular/app-shell@0.0.0 requires a peer of @angular/core@2.0.0-rc.1 but none was installed.
npm WARN @angular/forms@0.2.0 requires a peer of @angular/core@^2.0.0-rc.4 but none was installed.
npm WARN @angular/forms@0.2.0 requires a peer of @angular/common@^2.0.0-rc.4 but none was installed.
npm WARN @angular/forms@0.2.0 requires a peer of @angular/compiler@^2.0.0-rc.4 but none was installed.
npm WARN @angular/platform-server@2.0.0-rc.4 requires a peer of @angular/core@^2.0.0-rc.4 but none was installed.
npm WARN @angular/platform-server@2.0.0-rc.4 requires a peer of @angular/common@^2.0.0-rc.4 but none was installed.
npm WARN @angular/platform-server@2.0.0-rc.4 requires a peer of @angular/compiler@^2.0.0-rc.4 but none was installed.
npm WARN @angular/platform-server@2.0.0-rc.4 requires a peer of @angular/platform-browser@^2.0.0-rc.4 but none was installed.
npm WARN angular2-express-engine@0.15.2 requires a peer of angular2-universal@^0.104.5 but none was installed.
npm WARN angular2-hapi-engine@0.15.0 requires a peer of angular2-universal@^0.104.0 but none was installed.
andrscrrn commented 8 years ago

I'm getting the same error from a clean install.

Apparently it is just failing when you use the --mobile flag when you try to create a new project.

TypeError: Cannot read property 'makeCurrent' of undefined

I just did this and now it's working. Not sure if it make sense to create a PR with this fix. Can please someone validate if that would be the right solution?

adrw commented 8 years ago

Tried that and still no dice but I have a new error...

/Users/andrew/Sites/angular-todo/node_modules/angular-cli/node_modules/configstore/index.js:54
                throw err;
                ^

Error: EACCES: permission denied, open '/Users/andrew/.config/configstore/ember-cli.json'
You don't have access to this file.

    at Error (native)
    at Object.fs.openSync (fs.js:584:18)
    at Object.fs.readFileSync (fs.js:431:33)
    at Object.create.all.get (/Users/andrew/Sites/angular-todo/node_modules/angular-cli/node_modules/configstore/index.js:35:26)
    at Object.Configstore (/Users/andrew/Sites/angular-todo/node_modules/angular-cli/node_modules/configstore/index.js:28:44)
    at clientId (/Users/andrew/Sites/angular-todo/node_modules/angular-cli/node_modules/ember-cli/lib/cli/index.js:22:21)
    at module.exports (/Users/andrew/Sites/angular-todo/node_modules/angular-cli/node_modules/ember-cli/lib/cli/index.js:65:19)
    at module.exports (/Users/andrew/Sites/angular-todo/node_modules/angular-cli/lib/cli/index.js:106:10)
    at /usr/local/lib/node_modules/angular-cli/bin/ng:31:5
    at /usr/local/lib/node_modules/angular-cli/node_modules/resolve/lib/async.js:44:21
adrw commented 8 years ago

So I can get past that by using sudo or changing the permissions on that config file but it now dies partway into ng serve

19:34:59-andrew~/Sites/hello-mobile (master)$ sudo ng serve
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
Livereload server on http://localhost:49153
Serving on http://localhost:4200/
The Broccoli Plugin: [AppShellPlugin] failed with:
undefined

The broccoli plugin was instantiated at:
    at AppShellPlugin.Plugin (/Users/andrew/Sites/hello-mobile/node_modules/broccoli-plugin/index.js:10:31)
    at AppShellPlugin.CachingWriter [as constructor] (/Users/andrew/Sites/hello-mobile/node_modules/broccoli-caching-writer/index.js:21:10)
    at new AppShellPlugin (/Users/andrew/Sites/hello-mobile/node_modules/angular2-broccoli-prerender/dist/prerender.js:15:16)
    at Angular2App._buildTree (/Users/andrew/Sites/hello-mobile/node_modules/angular-cli/lib/broccoli/angular2-app.js:161:48)
    at new Angular2App (/Users/andrew/Sites/hello-mobile/node_modules/angular-cli/lib/broccoli/angular2-app.js:53:23)
    at module.exports (/Users/andrew/Sites/hello-mobile/angular-cli-build.js:10:10)
    at Class.module.exports.Task.extend.setupBroccoliBuilder (/Users/andrew/Sites/hello-mobile/node_modules/angular-cli/node_modules/angular-cli/lib/models/builder.js:55:19)
    at Class.module.exports.Task.extend.init (/Users/andrew/Sites/hello-mobile/node_modules/angular-cli/node_modules/angular-cli/lib/models/builder.js:89:10)
    at new Class (/Users/andrew/Sites/hello-mobile/node_modules/angular-cli/node_modules/core-object/core-object.js:18:12)
    at Class.module.exports.Task.extend.run (/Users/andrew/Sites/hello-mobile/node_modules/angular-cli/node_modules/angular-cli/lib/tasks/serve.js:15:19)
    at /Users/andrew/Sites/hello-mobile/node_modules/angular-cli/node_modules/angular-cli/lib/commands/serve.js:64:24
    at lib$rsvp$$internal$$tryCatch (/Users/andrew/Sites/hello-mobile/node_modules/angular-cli/node_modules/rsvp/dist/rsvp.js:1036:16)
    at lib$rsvp$$internal$$invokeCallback (/Users/andrew/Sites/hello-mobile/node_modules/angular-cli/node_modules/rsvp/dist/rsvp.js:1048:17)
    at /Users/andrew/Sites/hello-mobile/node_modules/angular-cli/node_modules/rsvp/dist/rsvp.js:331:11
    at lib$rsvp$asap$$flush (/Users/andrew/Sites/hello-mobile/node_modules/angular-cli/node_modules/rsvp/dist/rsvp.js:1198😔)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
MarkPieszak commented 8 years ago

What version of the CLI are you using? There are some general issues that need to be fixed up with CLI & Universal at the moment. @andrewparadi I (believe) using an older version, I forget which solves them at least for now.

andrscrrn commented 8 years ago

@andrewparadi Try npm cache clean, rm -rf node_modules and then npm install

filipesilva commented 8 years ago

@andrewparadi it's likely enough that the next CLI beta will have changed the build process to use webpack, and with that also changed the way mobile apps are built. So in that sense the next beta release should fix all these issues I think.

adrw commented 8 years ago

@andresdavid90 thanks, unfortunately didn't help. @MarkPieszak

angular-cli: 1.0.0-beta.9
node: 5.11.0
os: darwin x64

@filipesilva hopefully! this has been a really rough start to the supposedly simple angular-cli. then again it's still alpha so I was expecting some of this.

andrscrrn commented 8 years ago

@filipesilva Great to know that! Hope to see that update soon. ✌🏻

MauroJr commented 8 years ago

I managed to solve this problem updating the version of "angular2-broccoli-prerender" and "angular2-universal", make sure you are using the version of angular-cli 1.0.0-beta.9 and type the following and will work:

ng new <PROJECT_NAME>
cd <PROJECT_NAME>
npm uninstall --save-dev angular2-broccoli-prerender
npm uninstall --save-dev angular2-universal
npm cache clear
npm install --save-dev angular2-broccoli-prerender
npm install --save-dev angular2-universal
npm install
npm start

or simply change the versions on package.json and run npm install...

"angular2-broccoli-prerender": "^0.11.5",
"angular2-universal": "^0.104.5"
adrw commented 8 years ago

Thanks!! It works 😄 (still needs sudo but not the end of the world)

14:26:16-andrew~/Sites/progress-angular (master)$ ng serve
/Users/andrew/Sites/progress-angular/node_modules/angular-cli/node_modules/configstore/index.js:54
                throw err;
                ^

Error: EACCES: permission denied, open '/Users/andrew/.config/configstore/ember-cli.json'
You don't have access to this file.

    at Error (native)
    at Object.fs.openSync (fs.js:584:18)
    at Object.fs.readFileSync (fs.js:431:33)
    at Object.create.all.get (/Users/andrew/Sites/progress-angular/node_modules/angular-cli/node_modules/configstore/index.js:35:26)
    at Object.Configstore (/Users/andrew/Sites/progress-angular/node_modules/angular-cli/node_modules/configstore/index.js:28:44)
    at clientId (/Users/andrew/Sites/progress-angular/node_modules/angular-cli/node_modules/ember-cli/lib/cli/index.js:22:21)
    at module.exports (/Users/andrew/Sites/progress-angular/node_modules/angular-cli/node_modules/ember-cli/lib/cli/index.js:65:19)
    at module.exports (/Users/andrew/Sites/progress-angular/node_modules/angular-cli/lib/cli/index.js:106:10)
    at /usr/local/lib/node_modules/angular-cli/bin/ng:31:5
    at /usr/local/lib/node_modules/angular-cli/node_modules/resolve/lib/async.js:44:21
msegers commented 8 years ago

Heya, I'm trying to mess around with universal and would like to take CLI with it as well. Am I missing some steps you mention here (Can't find any quick tutorials or quick start guides).

Is there any quickstart guide with both universal and cli or should I just mess around with the demo app?

It is quite confusing since the demo uses weback and such. I've got one project with it running and I'm quite happy with it but I can't see a easy way to migrate it onto cli, many packages only have install guides for the Angular CLI these days.

MarkPieszak commented 8 years ago

The CLI is actually moving to Webpack very shortly as well, so that'll make adding the necessary Universal (server-side) additions even easier for you (The Universal-Starter repo has the basic setup for Express). @msegers

PatrickJS commented 8 years ago

closing as there were a lot of changes for universal and the cli

angular-automatic-lock-bot[bot] commented 5 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.