I've just started programming in Node.js and in Azure DevOps. I've tried to run a simple Node.js example to see how things work in Azure DevOps, but I've encountered an error and I don't know how to get past it. I have this file imported from Github (File1.js):
const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World\n');
});
server.listen(port, hostname, () => {
console.log('Server running at http://${hostname}:${port}/');
});
And in my azure-pipelines.yml I have the following code:
# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/javascript
pool:
vmImage: 'Ubuntu 16.04'
steps:
- task: NodeTool@0
inputs:
versionSpec: '11.x'
displayName: 'Install Node.js'
- task: Npm@1
displayName: 'npm install'
inputs:
command: install
- script: npm compile 'File1.js'
I know the last line from the .yml file generates an error, but I don't know how to make the connection to the .js file in order to run it. If I take out that line, everything works fine, but... it doesn't run the file... Please help with any solutions/hints. They will be very much appreciated! Thank you!