Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...