0

I have one existing project ActivityManagement and I am making a new project SourceManagement.

enter image description here

Now this component of Banner , footer and header I want to use it in my new project.
How can I use them ?

Also one thing, the old project ActivityManagement > uses old version of

   "@angular-devkit/build-angular": "^14.1.2",

while my new angular project SourceManagement is using

   "@angular-devkit/build-angular": "^16.0.0",

I can change the version of new project to lower version.

What all steps need to be considered while doing this change ?

P.S - I am new to development and trying out various combinations as, if the copy pasting works it will be really helpful as I need to make such small small projects with same component.

I tried copy pasting the existing project package.json in new project file, and then tried to ng build but getting error while ng build

enter image description here

2 Answers2

1

Don't start with package.json. That's the file which will vary the most.

Just copy the component files (.scss, .ts, .spec.ts, .html inside banner/, footer/ and header/), then import proper dependecies and either assign them to a module or declare them as standalone.

You might need to install additional dependecies in case of your components use third party libraries, which are not yet installed in SourceManagement project.

mhld
  • 163
  • 2
  • 9
0

The devkit version indicates the version of Angular you're using. You're trying to go from 14 to 16, and lot of things have changed, especially the polyfills management, which is the source of your error.

Copy/pasting works only when you have coded your components very properly (single responsibility, isolation, etc). Since you are starting as you stated, I doubt you can do that.

What I would suggest to you, is to either copy/paste the component you want and resolve every error one by one, or create a library, which would teach you how angular manages shared code.

Even better, you could make a monorepository with both your applications in it, and the library as well !

Here is the documentation to get you started on the latter 2 proposals.

MGX
  • 2,534
  • 2
  • 14