Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

azure command line script to run node js command

I have hosted a nodejs app on azure linux. Now, I am trying to run command from my machine to invoke node js cli command. I am looking for an ability to run the script from my local machine on server.

I am trying

az vm run-command invoke -g xxx -n yyy --command-id RunShellScript --scripts “NODE_ENV_VAR_LIST node dist/app.js arg1 “

Output , it say provisioning is successful but throw error while running

"Enable succeeded: 
[stdout]

[stderr]
module.js:549
    throw err;
    ^

Error: Cannot find module '/var/lib//run-command/download/2/dist/app.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3
",

any help is appreciated?

question from:https://stackoverflow.com/questions/65835232/azure-command-line-script-to-run-node-js-command

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think the error gives enough message. Let's analyze it again. The success means the script NODE_ENV_VAR_LIST node dist/app.js arg1 was executed in the VM, if it does not succeed, then it means VM does not execute the command.

And the error after is about the command, it means there is something wrong with the command itself. And the issue is also clear, you use the relative path and it causes the issue. You need to use the absolute path for the app file in the command.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...