简体   繁体   中英

Using Parse with Angular2 (TypeScript)

(Yes, I know angular2 is beta, but I'm just trying it out)

I've followed the angular2 quickstart here: https://angular.io/docs/js/latest/quickstart.html

And that's working fine. Now I want to try to use it with Parse, so I found out tsd was probably the way to go to access Parse from TypeScript.

I went on and did:

tsd init
tsd install parse --save

It added Parse (parse.d.ts) + its dependencies (node.d.ts, jquery.d.ts and underscore.d.ts.

Now, the node.d.ts part was abit problematic since angular2 already had this added, so each definition was duplicated, I tried to solve this by:

Remove "typings/node" folder (node/node.d.ts)
Remove '/// <reference path="node/noded.ts" />' from typings/tsd.d.ts
Remove '/// <reference path="node/noded.ts" />' from typings/parse/parse.d.ts

I figured, this will work since node.d.ts is available already, right?

Well, it's not working and I have no clue why. I get an error node_modules/angular2/typings/angular-protractor/angular-protractor.d.ts(1679,13): error TS2403: Subsequent variable declarations must have the same type. Variable '$' must be of type 'JQueryStatic', but here has type 'cssSelectorHelper'. node_modules/angular2/typings/angular-protractor/angular-protractor.d.ts(1679,13): error TS2403: Subsequent variable declarations must have the same type. Variable '$' must be of type 'JQueryStatic', but here has type 'cssSelectorHelper'. But this is not the main problem, because it looks like proceeds after that.

This is what makes npm start "crash":

[1] events.js:141
[1]       throw er; // Unhandled 'error' event
[1]       ^
[1] 
[1] Error: watch node_modules/angular2/es6/dev/examples/core/ts/bootstrap/bootstrap.js ENOSPC
[1]     at exports._errnoException (util.js:855:11)
[1]     at FSWatcher.start (fs.js:1313:19)
[1]     at Object.fs.watch (fs.js:1341:11)
[1]     at createFsWatchInstance (/home/david/repo/angular2-toodeloo/node_modules/chokidar/lib/nodefs-handler.js:37:15)
[1]     at setFsWatchListener (/home/david/repo/angular2-toodeloo/node_modules/chokidar/lib/nodefs-handler.js:80:15)
[1]     at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/david/repo/angular2-toodeloo/node_modules/chokidar/lib/nodefs-handler.js:228:14)
[1]     at FSWatcher.NodeFsHandler._handleFile (/home/david/repo/angular2-toodeloo/node_modules/chokidar/lib/nodefs-handler.js:255:21)
[1]     at FSWatcher.<anonymous> (/home/david/repo/angular2-toodeloo/node_modules/chokidar/lib/nodefs-handler.js:473:21)
[1]     at FSReqWrap.oncomplete (fs.js:82:15)

Full output can be found here: http://pastebin.com/xE3u3qUh

UPDATE

I relized the error above was in the angular2 examples, so I removed the examples and got rid of the error. But when I did "npm install parse", the error was back, but in another place.. This time: Error: watch node_modules/opt-merger/node_modules/lodash/lang/isFunction.js ENOSPC

The reason I got this was that there was to many watches (inotify) in the filsystem. See https://unix.stackexchange.com/questions/13751/kernel-inotify-watch-limit-reached%E2%80%8C%E2%80%8B for how to increment the maximun number of watches!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM