I want to create a batch file to execute my Angular project:
setlocal
cd /d %~dp0
cd ui
npm i && npm start
The file simply goes to the current directory, and then goes to ui
folder. First runs a npm i
command, and then runs nmp start
command. The problem is the second commands gives me the following error:
npm ERR: path C.\Windows\System32\package.json
...
Surprisingly the locations is changed to C:\Windows\System32\
and npm start
command can not find a package.json
file there. I want to know why does it happen and how I can prevent it. I want the second command to be executed at the same directory.
As @Compo suggested, adding a call at the beginning of the last line solved the problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.