Unable to create resource in nestjs due to typeScript compatibility issue

Encountered an Error:

TypeError: Cannot access 'properties' property of undefined

Failed to execute command: 
node @nestjs/schematics:resource --name=post --no-dry-run --language="ts" --sourceRoot="src" --spec

Attempts made so far:

npm i -g @nestjs/schematics    

as well as

npm install --save-dev <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="403725223021232b6d232c2900736e716e71">[email protected]</a>   

but neither solution resolved the issue.

Error occurs when creating new resources using nest g resource

package.json

{
  "name": "nestjs",
  "version": "0.0.1",
  "description": "",
  "author": "",
  "private": true,
  "license": "UNLICENSED",
  "scripts": {
    "prebuild": "rimraf dist",
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "nest start",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json"
  },
  "dependencies": {
    "@hapi/joi": "^17.1.1",
    "@nestjs/common": "^8.0.0",
    "@nestjs/config": "^2.0.0",
    "@nestjs/core": "^8.0.0",
    "@nestjs/jwt": "^8.0.0",
    "@nestjs/mapped-types": "*",
    "@nestjs/passport": "^8.2.1",
    "@nestjs/platform-express": "^8.0.0",

    // Remaining dependency entries truncated for brevity...
    
  }
}

ts config

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "skipLibCheck": true,
    "strictNullChecks": true,
    "noImplicitAny": false,
    "strictBindCallApply": false,
    "forceConsistentCasingInFileNames": false,
    "noFallthroughCasesInSwitch": false
  }
}

Edit: Another unsuccessful attempt that was made:

npx nest g resource post

Answer №1

Dealing with a similar problem, I discovered that my global and local Nest CLI versions were not in alignment. To rectify the issue, I executed the following command:

npm i -g @nestjs/cli

After carrying out this step, all functionalities are now operating smoothly.

Answer №2

My project was not updated, and I only updated some dependencies which caused it to stop working.

To fix this issue, I ran the following commands:

nest update -f -t latest 

or

yarn upgrade-interactive --latest

Once that was done, I installed the required package by running:

yarn global add @nestjs/schematics

Now everything is working perfectly!

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

The issue of `function.prototype` not functioning correctly when used alongside `module

I have a file that contains a current function implementation function bar(){ /*Code goes here*/ } bar.prototype.method = function(param){ /*Some code*/ return this } module.exports = bar In the test file, I encountered some issues, let y = requir ...

How do I set up middleware with async/await in NestJS?

I am currently integrating bull-arena into my NestJS application. export class AppModule { configure(consumer: MiddlewareConsumer) { const queues = this.createArenaQueues(); const arena = Arena({ queues }, { disableListen: true }); consumer. ...

What causes an array of type `never[] & number[]` to be generated when using `Object.assign`?

Take a look at this code snippet: const arr = [1,2,3] const res1 = arr.slice() const res2 = Object.assign([],arr) When using arr.slice() to create a shallow clone, the resulting array res1 will have a type of number[], just like the original arr. However, ...

Passing data from getServerSideProps to an external component in Next.js using typescript

In my Index.js page, I am using serverSideProps to fetch consumptions data from a mock JSON file and pass it to a component that utilizes DataGrid to display and allow users to modify the values. export const getServerSideProps: GetServerSideProps = async ...

Encountering NODE_MODULE_VERSION error during testing, but not during actual execution in LevelDOWN

In my project, I have a configuration file called .npmrc which contains the following settings: runtime = electron target = 1.7.9 target_arch = x64 disturl = https://atom.io/download/atom-shell build_from_source = true I also have a package.json file wit ...

The sequence of operations when assigning in Typescript with || and utilizing the array .find method

I need to ensure that the operations in my assignment are happening in a specific sequence. As far as I can tell, it should be following the order listed below. However, I have not been able to locate any documentation on TypeScript that definitively confi ...

Troubleshooting issue with the spread operator and setState in React, Typescript, and Material-ui

I recently developed a custom Snackbar component in React with Material-ui and Typescript. While working on it, I encountered some confusion regarding the usage of spread operators and await functions. (Example available here: https://codesandbox.io/s/gift ...

Guide to releasing a NestJs library on npm using the nrwl/nx framework

Struggling with creating a publishable NestJS library using NX. Despite reading numerous documentations, I still can't figure it out. I've developed a NestJS library within an NX monorepository and now I want to publish just this library on NPM, ...

The Intersection of Material-UI, TypeScript, and Powerful Autocomplete Features

In my TypeScript project, I'm attempting to develop a Material-UI AutoComplete component that retrieves the input value based on an object's property name -> obj[key] However, when using the prop getOptionLabel, I encountered the following er ...

Having trouble importing DropDown and MenuButton components from materialUI Joy

As I attempt to create a simple menu dropdown using Dropdown and MenuButton from the MaterialUI Joy library, I encountered an issue. After installing the library, I could not locate the DropDown and MenuButton folders within the 'joy' directory i ...

I am encountering issues installing Nativescript on my Windows system using npm

Trying to set up NativeScript on a Windows 10 machine, I ran into an issue when entering the command: npm install -g nativescript The error message that appeared was: D:\workspace\projects>npm install nativescript@next -g npm ER ...

How is it that void can be assigned undefined?

According to the documentation on typescript, it states that "the one exception being that undefined is also assignable to void". Source Strict null checking mode specifies that null and undefined values are not within the domain of every type and can o ...

Exploring observables for querying the OMDB API and obtaining information on movies

Hey everyone, I'm currently working on implementing a live search feature using Observables in Angular2 to fetch Movie data from the OMDB API. While I can see that it is functioning correctly in the Chrome Network tab, the results aren't showing ...

Setting up the NPM version specifically for Dependabot

I have configured my dependabot.yml file for dependabot to automatically update my NPM dependencies as follows: version: 2 updates: - package-ecosystem: npm directory: "/" schedule: interval: monthly rebase-strategy: auto However, I no ...

Issue encountered when attempting to assign `fontWeight` within `makeStyles` using `theme` in Typescript: Error message states that the property is not

Currently, within my NextJS project and utilizing MUI, I am attempting to define a fontWeight property using the theme settings in the makeStyles function. Oddly enough, this issue only arises when building inside a docker container, as building locally po ...

Leveraging npm packages within a Meteor project through cosmos:browserify

Trying to implement Radium, a JavaScript library for inline CSS, by following the instructions located here. In my app.browserify.js file: Radium = require("radium"); Within package.json: "radium": "0.13.4" Upon attempting to utilize Radium in the app&a ...

When running npm install, an ERESOLVE error message may appear indicating that a resolution could

Upon executing npm install, I encounter the following error message: code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: @angular-devkit/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d8baadb1b ...

What is the best way to handle node module dependencies when you have made custom code modifications within the dependencies?

Currently, I am in the midst of developing a react-native mobile application for both Android and iOS. A certain issue has arisen where I needed to make modifications to a NavigationReactGateway.java file located within the node_modules/react-native-naviga ...

Tips for properly setting up an npm module with a babel compiler

I have developed an npm module which utilizes Babel to convert es6/es7 code. The prepublish script is defined as follows: "scripts": { "build": "babel -d dist/ src/", "prepublish": "yarn run build", }, "main": "dist/index.js", Upon running npm ...

script not found: typings-install

When running the command npm run typings-install, I encountered the following error: npm ERR! Windows_NT 6.1.7601 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\n ...