AWS Amplify Angular JS sample code not working on local machine


Steps given to get started with Angular.js to run in local is failing with compilation error.

import { Customer } from './models'; Above line is throwing an error: "Cannot find module './models' or its corresponding type declarations"

asked a year ago1257 views
2 Answers

From the note I understand you want to import { Customer } from './models'; from Angular JS and is throwing an error: "Cannot find module”.

Please note the "Cannot find module or its corresponding type declarations" error occurs when TypeScript cannot locate a third-party or local module in our project. To solve the error, make sure to install the module and try setting moduleResolution to node in your tsconfig. json file.

If the module is a third-party module, make sure you have it installed.

shell npm install module-name npm install --save-dev @types/module-name

Make sure to replace module-name with the name of the module in your error message.

I hope this helps.


answered a year ago

Check TypeScript Configuration: Could you verify that the TypeScript configuration in your AngularJS project is correctly set up?

In your tsconfig.json file, you might have something like:

"baseUrl": "./src",
"paths": {
  "@app/*": ["app/*"]

Then, you can import your models using the configured path:

import { Customer } from '@app/models';
answered 4 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions