1
votes

I am trying to publish my code to azure web app services through azure devops, i have added the code to build repo by creating a folder and it is simple hello world nodejs app, which is working file in local system, But when i create a new build i get this error

npm ERR! enoent ENOENT: no such file or directory, open '/home/vsts/work/package.json'

Found npm debug log, make sure the path matches with the one in npm's output: /home/vsts/.npm/_logs/2020-01-20T10_30_12_597Z-debug.log 0 info it worked if it ends with ok 1 verbose cli [ '/opt/hostedtoolcache/node/10.14.1/x64/bin/node', 1 verbose cli '/opt/hostedtoolcache/node/10.14.1/x64/bin/npm', 1 verbose cli 'run', 1 verbose cli 'build', 1 verbose cli '--if-present' ] 2 info using [email protected] 3 info using [email protected] 4 verbose stack Error: ENOENT: no such file or directory, open '/home/vsts/work/package.json' 5 verbose cwd /home/vsts/work/8/s 6 verbose Linux 4.15.0-1064-azure 7 verbose argv "/opt/hostedtoolcache/node/10.14.1/x64/bin/node" "/opt/hostedtoolcache/node/10.14.1/x64/bin/npm" "run" "build" "--if-present" 8 verbose node v10.14.1 9 verbose npm v6.4.1 10 error path /home/vsts/work/package.json 11 error code ENOENT 12 error errno -2 13 error syscall open 14 error enoent ENOENT: no such file or directory, open '/home/vsts/work/package.json' 15 error enoent This is related to npm not being able to find a file. 16 verbose exit [ -2, true ] npm ERR! A complete log of this run can be found in: npm ERR! /home/vsts/.npm/_logs/2020-01-20T10_30_12_597Z-debug.log ##[error]Error: Npm failed with return code: 254 ##[section]Finishing: Run 'build' script

Kindly help in resolving this error.

2

2 Answers

0
votes

Are you using private agents on VSTS?

0
votes

Build failed in azure devops even though package.json file is present in the Repo

First check your path /home/vsts/work/ does this really has package.json file, if not, then you have to install npm again (command "npm init") to ensure package.json file appears in the same directory as mentioned in your error.

Besides, if you have any package-lock.json in your repo, try to remove it and run the pipeline again.

If above not help you resolve your question, please share your build definition to us.

Hope this helps.