Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
Ejecutando una aplicación angular usando el nodo js

Tengo una página html y un serviceController.js, necesito ejecutar automáticamente la aplicación a través del nodo js. Lo siento por la pregunta ingenua, pero no puedo ejecutarlo. Mi serviceController.js se ve así:

 var app = angular.module("app", []); app.controller('serviceController', ['$scope', '$interval','$http', function($scope, $interval, $http) { $scope.service1 = {//and so on.. }

Estaba siguiendo un ejemplo y probé lo siguiente: creé un paquete.json:

 { "name": "express-html", "version": "0.0.1", "dependencies": { "express": "^4.11.0" }}

Mi server.js se ve así:

 var express = require("express"); var app = express(); var path = require("path"); app.get('/',function(req,res){ res.sendFile(path.join(__dirname+'/index.html')); }); app.listen(3000); console.log("Running at Port 3000");

Pero, cuando intento iniciar la aplicación desde la terminal usando: node server.js. Obtuve el siguiente error :

 (function (exports, require, module, __filename, __dirname) { var app = angular.module("app", []); ^ReferenceError: angular is not defined at Object.<anonymous> (/Users/dem/Desktop/frontend/task3/serviceController.js:1:81) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object.<anonymous> (/Users/dem/Desktop/frontend/task3/server.js:5:19) at Module._compile (module.js:570:32)

¡Por favor guía!

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

app.use("/", express.static(__dirname)); Use esto en lugar de

res.sendFile(ruta.join(__dirname+'/index.html'));

about 4 years ago · Santiago Trujillo Report

0

Actualice el archivo del servidor para servir un directorio estático como app.use(express.static('dirPath')) Para obtener más detalles, visite Sirviendo archivos estáticos en Express

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!