IntelliJ configuration issue with Angular 2: Module '@angular/core' not found

Exploring Angular2 for the first time with a tutorial called "guess-the-number."

Following the instructions on GitHub, Tutorial Angular2 by Example, was a breeze until I encountered an error in IntelliJ. The code works fine in the browser, but something seems off in my IntelliJ setup.

The specific error message reads: "Cannot find module '@angular/core'." See the screenshot below for reference:

https://i.sstatic.net/0FmiK.png

In an attempt to troubleshoot, I checked my properties file, which looks like this:

systemjs.config.js

System.config({
map : {
    'app': 'app',
    'rxjs': 'https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="72000a180132475c425c425f101706135c4340">[email protected]</a>',
    '@angular/common': 'https://unpkg.com/@angular/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d9bab6b4b4b6b799ebf7e9f7e9">[email protected]</a>',
    '@angular/compiler': 'https://unpkg.com/@angular/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="80e3efedf0e9ece5f2c0b2aeb0aeb0">[email protected]</a>',
    '@angular/core': 'https://unpkg.com/@angular/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6b0804190e2b59455b455b">[email protected]</a>',
    '@angular/platform-browser': 'https://unpkg.com/@angular/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="46362a27322029342b6b24342931352334067468766876">[email protected]</a>',
    '@angular/platform-browser-dynamic': 'https://unpkg.com/@angular/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="71011d1005171e031c5c13031e060214035c15081f101c181231435f415f41">[email protected]</a>'
},
packages:{
    'app':  { main: 'main.ts',  defaultExtension: 'ts' },
    '@angular/common': { main: 'bundles/common.umd.js', defaultExtension: 'js' },
    '@angular/compiler': { main: 'bundles/compiler.umd.js', defaultExtension: 'js' },
    '@angular/core': { main: 'bundles/core.umd.js', defaultExtension: 'js' },
    '@angular/platform-browser': { main: 'bundles/platform-browser.umd.js', defaultExtension: 'js' },
    '@angular/platform-browser-dynamic': { main: 'bundles/platform-browser-dynamic.umd.js', defaultExtension: 'js' },
},
// DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
transpiler: 'typescript',
typescriptOptions: {
    emitDecoratorMetadata: true
}
});

Possible solutions to the issues?

  1. Considering hosting files locally instead of linking them through external URLs like https://unpkg.com/@angular/[email protected].

  2. IntelliJ might not recognize the systemjs.config.js file. Should I create a tsconfig.json file to make it more understandable for IntelliJ?

Answer №1

The issues are originating from the TypeScript compiler. Similar to IntelliJ IDEA, it cannot locate @angular modules through CDN references in your system configuration; instead, these modules must be locally available within your project (installed via npm - refer to https://angular.io/docs/ts/latest/guide/setup.html for guidance). The current setup you have will function properly only when utilizing browser-based compilation.

Answer №2

Creating a tsconfig.json file is essential for your project,

Make sure to enable the TypeScript compiler in IntelliJ Settings as well

https://i.sstatic.net/l3VSr.png

You may also find this resource helpful too

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

One property of a JavaScript object unable to be accessed by another property (which is a

I need some help with a problem I am encountering. Whenever I reference weekdays inside the function change_date(), Firebug shows an error message saying weekdays is undefined. Even when I tried using this.weekdays, the same issue occurred. How can I fix ...

Interactive Three JS Shapes (unveiling images upon clicking)

I modified an example I found on the three js website. My goal is to add a click event to the small floating objects. When clicked, the event will reveal an image or video on the larger convex shape in the center. Idea + Visuals Check out the Working S ...

AngularJS Filter without creating a new object

Within my code, I am dealing with an array of objects that contain sub-objects. This particular array is utilized in an ng-repeat to display data in a table format. To illustrate, consider the following example: device { "name": "computer" ...

Retrieving a value with document.getElementById("") results in an object being returned instead of a value

I have a dataset in the format shown below: { USA: { CA: { 'SAN FRANCISCO':['94188', '94158', '94143'] }, LA: { 'BATON ROUGE':['70898','70895','70891'] } } } I am ...

When iterating through a loop, I encounter difficulties accessing array values, yet the values are visible when written to the console

Currently, I am facing a peculiar issue where I retrieve the user's profile from Firebase, and within this profile lies a Photo Object containing an array of photos uploaded by the user. This is my getUserProfile method: getUserProfile(): Observable ...

What is the best way to encode a type that necessitates a specific superclass and interface implementation?

In order to achieve my goal, I need to extend a library class that is part of the React components I am creating. Here's an example of the original library class I'm working with: class ReactComponent<T, U> { render() { return "some ht ...

Using a custom validator in Angular that accepts an array as input

My special code: <input mdInput [mdAutocomplete]="auto" [(ngModel)]="formData.areaName" (keyup)="updateFilteredAreas(formData.areaName)" class="form-control {{areaName.errors ...

Error with JavaScript slideshow The slideshow using JavaScript seems to

I'm currently utilizing a script from the WOW Slider (free version) that looks like this: var slideIndex = 0; function showSlides() { var i; slides = document.getElementsByClassName("mySlides"); dots = document.getEle ...

Learn how to retrieve data from the console and display it in HTML using Angular 4

Need help fetching data inside Angular4 HTML from ts variable. Currently only able to retrieve 2 data points outside the loop. Can anyone assist with pulling data inside Angular4? HTML: <tr *ngFor="let accept of accepts"> ...

What is the best way to center a slick slider both vertically and horizontally on a

I'm struggling to get my slick slider carousel perfectly centered in any browser, whether it's on desktop Chrome or an iPhone X Max. The slider is currently stuck at the top of the page and I've tried multiple solutions without success. Thi ...

How can I dispatch multiple actions simultaneously within a single epic using redux-observable?

I am a newcomer to rxjs/redux observable and have two goals in mind: 1) enhance this epic to follow best practices 2) dispatch two actions from a single epic Many of the examples I've come across assume that the API library will throw an exception ...

Guide to Retrieving and Showing an Image from an express backend server in a React js frontend

I am working on a project where I need to retrieve images from an express backend and display them in the React JS frontend. I want to know the best way to accomplish this successfully. My attempt involved fetching images stored in a folder named "Backup" ...

Storing Material-UI Choices Using Redux State

Looking to integrate a Material-UI Select component with Redux data for persistent selections after page refresh. Within Redux, I have two arrays: the sourceTags array, consisting of clickable menu options, and the selectedTags array, containing the user& ...

Click function for Angular bootstrap button

I have implemented a basic form in my template that already has validation. My main issue is how to check when the user clicks on the button after filling out all required fields? <section class="contact-area pb-80" style="margin-top:10%"> < ...

TypeScript's type assertions do not result in errors when provided with an incorrect value

We are currently using the msal library and are in the process of converting our javaScript code to TypeScript. In the screenshot below, TypeScript correctly identifies the expected type for cacheLocation, which can be either the string localStorage, the ...

Leveraging React Native's Async Storage to store and retrieve values consistently within the Render method

Is there a way to set and get a value in the render method with just one line of code, by using a variable between tags? I attempted this approach but encountered an error message stating "Can't find variable: storage_key". import React, { Component } ...

Can anyone suggest an effective method for displaying images using JavaScript by specifying a route and filename?

Currently, I have the following code snippet: const route = '/Images/Banner/'; const slides = [ { name: "banner-01", url: `${route}banner-01.png` }, { name: "banner-02", url: `${route}banner-02.pn ...

Utilizing the Node.js `cluster` module in TypeScript/CommonJS with DT @types/[email protected]

I am currently managing a TypeScript application using Node's cluster API that was successfully built with Node 14.x and the cluster types from DT. Upon transitioning this application to Node 16.x, I updated the @types/node package from version 14.x ...

Attempting to request information from a GraphQL API and then transferring it as properties to a component

I am currently in the process of learning GraphQL and TypeScript, so I decided to practice by working with this API https://github.com/trevorblades/countries. My goal is to fetch data from the API in my React application's HomeComponent and then pass ...

What is the process for activating focus on an input element within a mat-select component?

How can I activate the cursor on the HTML input element (search field) using a keyboard inside mat-select? It functions properly when using a mouse, but in order to meet WCAG requirements, it needs to be fully functional with keyboard navigation. Click h ...