Unable to locate the 'typescript' module at <Path>. However, the tsc -v command displays logs

I have a project using nrwl/nx and I set up the workspace(morningharwood) and an app(portfolio) on my home computer (windows). Now, I have cloned the repository, installed the dependencies with yarn install, and attempted to run it on my mac. However, I encountered an error when running

node_modules/.bin/ng serve --app=portfolio
which says
Cannot find module 'typescript' from '/Users/m/projects'
even though typescript is installed both locally and globally:

Question: Why is my project unable to locate typescript? How can I successfully execute my project on my mac?

m@mac: ~/projects/ on feature/prerender [?]
$ tsc -v
Version 2.6.1

m@mac: ~/projects/morningharwood/platform on feature/prerender [?]
$ node_modules/.bin/ng serve --app=portfolio

Cannot find module 'typescript' from '/Users/m/projects'
Error: Cannot find module 'typescript' from '/Users/m/projects'
    at Function.module.exports [as sync] (/Users/m/projects/morningharwood/platform/node_modules/resolve/lib/sync.js:40:15)
    at Object.requireProjectModule (/Users/m/projects/morningharwood/platform/node_modules/@angular/cli/utilities/require-project-module.js:6:28)
    at Object.readTsconfig (/Users/m/projects/morningharwood/platform/node_modules/@angular/cli/utilities/read-tsconfig.js:6:48)
    at new NgCliWebpackConfig (/Users/mharwood/projects/morningharwood/platform/node_modules/@angular/cli/models/webpack-config.js:19:42)
    at Class.run (/Users/m/projects/morningharwood/platform/node_modules/@angular/cli/tasks/serve.js:71:29)
    at check_port_1.checkPort.then.port (/Users/m/projects/morningharwood/platform/node_modules/@angular/cli/commands/serve.js:123:26)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
m@mac: ~/projects/morningharwood/platform on feature/prerender [?]

package.json

"devDependencies": {
  "ts-node": "^3.3.0",
  "tsconfig-paths": "^2.3.0",
  "tslint": "~5.3.2",
  "typescript": "2.4.2", 
}

Answer №1

This particular problem was successfully resolved through the efforts on issue 109 https://github.com/nrwl/nx/issues/109

Below is the solution:

The root cause of this issue lies in the ".angular-cli.json" file where the root property is set as "root": "apps\portfolio\src", modifying it to "root": "apps/portfolio/src" will rectify the error. I will implement this fix.

This correction should be included in the upcoming releases by nrwl.

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

Ways to restrict data types within function parameters

Can you validate types of one argument based on another argument in functions? Consider this example: interface Data { id?: number; name?: string; } let data : Data = {}; // I am unsure how to make the "value" argument strict function update(field : ...

Can the grunt command be executed automatically after saving code in TypeScript?

As a newcomer to FrontEnd and JavaScript coding in TypeScript, I find myself constantly needing to follow these steps after making a code change: save the code -> compile it using Grunt -> reload the webpage. It can be quite time-consuming. Is there ...

Creating organized lists in Angular 4 using list separators

I'm struggling to organize a list with dividers between categories to group items accordingly. Each divider should be labeled with the month name, and the items under it should correspond to that specific month. My Goal: - August - item 1 - item ...

Tips for retrieving the _id of Models in Mongoose using Typescript

I am currently using Mongoose to model MongoDB objects in my Node.js/NestJS project. Objective My goal is to expose the automatically generated _id of an object in a POJO, as I need it on the client side for various operations such as identifying the same ...

Ionic Firebase Scroll Dilemma

I have been attempting to automatically scroll to the bottom of a view when it loads, but I have tried several methods without success. Sometimes it stops in the middle of the screen, and I suspect this is because not all messages (30) are loaded yet. Her ...

RXJS buffering with intermittent intervals

Situation: I am receiving audio data as an array and need to play it in sequence. The data is coming in continuously, so I am using an observable to handle it. Since the data arrives faster than it can be played, I want to use a buffer to store the data w ...

Discover the method for extracting a value from an interface and incorporating it into a separate function

I need help accessing the value of userType for a conditional statement. UserType: const RadioForm = (props) => { return ( <div> <label>Customer</label> <input type="radio&qu ...

Adding a class to a child component layout from a parent component in Angular 12 and Typescript can be achieved by using the ViewChild decorator

Incorporating the child component into the parent component is an important step in the structure of my project. The dashboard component serves as the child element, while the preview component acts as the parent. Within the parent (preview) component.htm ...

How to update Select2 with a fresh item in Angular 2 (ng2-select2)

I'm currently implementing ng2-select2 within my Angular2 project. My goal is to allow users to create a new item if it's not present in the list (only one item), and then store that new item in my component.ts for later use in my submitForm func ...

Updating the navigation item list according to the content being shown: A step-by-step guide

I currently have a navigation menu set up with the following code: <ul class="menu-left pl-3"> <li *ngFor="let period of periods; let i = index">> <a class="mb-4 fragment-link" [class.active]="selectedIndex === i" ...

Detecting changes in an ondrop event triggered by a modification in object property

As I work on creating a drag and drop interface, I realize the importance of implementing change detection for smooth functionality. Below is a snippet of my component: import { Component, OnInit, ChangeDetectorRef } from '@angular/core'; impor ...

Using TypeScript's destructuring feature

Currently delving into the world of TypeScript and I've got a question regarding destructuring. Let's say I have an object that needs to be destructured before using the variables. Here's an example: type bookProps = { books: Book[], ...

Should original Typescript code be stored in the published node_module library or not?

When developing a node module in Typescript and preparing it for publishing, I have the option to publish only the transpiled (obfuscated) code contained in the /dist folder. Alternatively, I can also choose to publish the original code found in either the ...

Deploying an Angular application on Kubernetes Ingress with a custom path instead of the root path

My Angular application runs smoothly in the development environment. However, when I attempt to deploy it to a Kubernetes cluster and set up an ingress route for it, things do not function as expected. Specifically, I have configured the following ingress ...

Guide to transferring a zip file from a server to a client in nodejs

After creating a zip file on the server side, I am trying to figure out how to transfer it to the client side in order to enable downloading using the saveAs() function and placing it within a new Blob() function. Any suggestions on how to accomplish this? ...

Maintain a variable within the scope of _.forEach() that is separate from the array being iterated

Occasionally, I encounter a scenario where objects need to be pushed into a separate array based on the content of a looped array: let customArray: any[]; _.forEach(iteratedArray, (item:any) => { // some irrelevant code... customArray.push(item ...

MEAN Stack Development: Why does the timestamp stored by Node.js appear different from the time on my laptop in Dev Mode?

Can someone assist me with properly displaying the correct datetime stamp? For example, the time on my laptop is: 02-Oct-2021 11:14am (this is in India) The time stored by Node and displayed in Angular is 2021-10-02T05:44:09.022Z, which is 06:30 behind m ...

What could be causing the issue of custom Angular svg not displaying correctly?

I am struggling to incorporate custom SVGs into my Angular Material project. My method closely resembles what is shown in this stackblitz: https://stackblitz.com/edit/angular-taqtkq-izuc7e?file=app%2Ficon-svg-example.ts Despite attempting various paths, ...

Eliminate the AM and PM options from the input time selection dropdown menu in HTML

https://i.sstatic.net/wKeQk.png Is it possible to eliminate the AM / PM option from the input time format dropdown? The form builder currently uses a 24-hour format that includes the AM / PM field. ...

Ag-grid hack: Changing cell color in a row without utilizing the Cell Styles property within column definitions

[{ "uniqueIdentifier": "12345", "identifier": "UJHU", "latitude": 33.68131385650486, "longitude": -83.36814721580595, "cycle": "1" "speedLimit" ...