0

I'm making an an angular app that uses cookies. I'm testing it locally, using angular2-cookie/core and everything seems to be working fine.

But when I try to publish it on AzureDevOps it breaks, with this error message:

ERROR in app/app.module.ts(50,39): Error during template compile of 'AppModule' Could not resolve angular2-cookie/core relative to /home/vsts/work/1/s/PictureLink.UI/ClientApp/src/app/app.module.ts.. src/app/app.module.ts(16,31): error TS2307: Cannot find module 'angular2-cookie/core'. [/home/vsts/work/1/s/PictureLink.UI/PictureLink.UI.csproj]

I am losing my damn mind. Why does it work fine here and not there? What can I even try to change?

Alex
  • 81
  • 1
  • 5
  • 1
    I guess you did not install the package properly. You probably installed it with -dev. Deletes this package when you get the build from the project. Please reinstall the package with the following command and check in the package.json: npm install angular2-cookie --save – Mahdi Jan 13 '21 at 21:09
  • How is it going with this case? Did below answer fix above issue? – Levi Lu-MSFT Jan 19 '21 at 09:08

1 Answers1

1

The error seems to be caused by the angular2-cookie package not being installed in azure pipeline.

1,You can go to the package.json file to check if the angular2-cookie package is added to the dependencies or devDependencies. If not, you need to run npm install angular2-cookie locally. npm install command will automatically add angular2-cookie to dependencies. Or you can manually add angular2-cookie to dependencies. Then push the changes to git repo.

2,Then you also need to check your pipeline task. You need npm task or a script task to install the dependencies. Please check here for examples.

- script: npm install

- task: Npm@1
  inputs:
  command: 'install'

Please check if you add some flags(ie.--production, --only ...) to the npm install command in your pipeline (eg. npm install --only=dev). If you use one of these flags in npm istall command. It will will cause some packages not being installed.

it is recommanded to use npm install, for it will install all the packages listed in dependencies and devDependencies.

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43