Closed fipsofant closed 7 years ago
npm WARN This failure might be due to the use of legacy binary "node"
Ein neueres nodejs installieren. 0.10.29 auf deinen System ist schon etwas alt (andererseits, ich hab noch eine 0.8 in production)
Oh, und ich dachte die Debian Version ist zumindest halbwegs aktuell... DANKE Jetzt klappt npm start zwar, aber wenn ich die Seite aufrufe zeigt es mir keine Daten an, weil er die /api nicht finden kann... Was für ein Tag -.-
Oh mann... ich habe den code jetzt entsprechen angepasst damit sie gefunden wird ABER jetzt krieg ich wieder diese Meldung: [Error] Failed to load resource: Origin http://dev.server.internal is not allowed by Access-Control-Allow-Origin. (api, line 0) [Error] XMLHttpRequest cannot load http://dev.server.internal:8080/api due to access control checks.
Hatte das auch schon wenn ich einen einfach Ajax get request an die Wiener Linien schicke, wie umgeht man den das bitte??
ist dev.server.internal dein hostname?
@fipsofant du kannst wegen CORS keine Requests direkt an die Wiener Linien API aus deinem Browser machen, deswegen macht das Öffimonitor Backend das für dich. Das Backend requested alle paar Sekunden neue Daten von der WLAPI, schmeißt unnötige Daten weg und stellt sie dann umformatiert unter /api
zur Verfügung.
Der Server für /
und /api
hat aber auch keinen Access-Control-Allow-Origin
Header gesetzt, weil davon ausgegangen wird, dass das /
und /api
vom selben Host kommen. Wenn das nicht der Fall ist (also entweder Server, Port oder beides unterschiedlich ist), musst du den passenden Header setzen, damit CORS erlaubt wird. Das sollte mit Express ganz leicht gehen, entweder du verwendest dafür eine Middleware oder setzt den Header selbst, siehe stackoverflow.
Danke Danke Danke für deine/eure tollen Tipps die haben mir weitergeholfen, jetzt klappt es.
Wie kann ich das lösen??
Hier der Output: root@dev:/var/www/dev.server.internal/oeffi# npm start
/var/www/dev.server.internal/oeffi/server/httpd.js:8 let app = express() ^^^ SyntaxError: Unexpected identifier at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:906:3
npm ERR! oeffimonitor@0.1.2 start:
NODE_ENV='production' node server/httpd.js
npm ERR! Exit status 8 npm ERR! npm ERR! Failed at the oeffimonitor@0.1.2 start script. npm ERR! This is most likely a problem with the oeffimonitor package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! NODE_ENV='production' node server/httpd.js npm ERR! You can get their info via: npm ERR! npm owner ls oeffimonitor npm ERR! There is likely additional logging output above. npm ERR! System Linux 4.4.35-1-pve npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "start" npm ERR! cwd /var/www/dev.server.internal/oeffi npm ERR! node -v v0.10.29 npm ERR! npm -v 1.4.21 npm ERR! code ELIFECYCLE npm WARN This failure might be due to the use of legacy binary "node" npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debiannpm ERR! npm ERR! Additional logging details can be found in: npm ERR! /var/www/dev.server.internal/oeffi/npm-debug.log npm ERR! not ok code 0