Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'wrap-ansi' #11660

Closed
3 of 15 tasks
dyonathakramer opened this issue May 24, 2023 · 6 comments
Closed
3 of 15 tasks

Cannot find module 'wrap-ansi' #11660

dyonathakramer opened this issue May 24, 2023 · 6 comments
Labels
needs triage This issue has not been looked into

Comments

@dyonathakramer
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When i start the app with nest start:

image

Already tried to change to nest/cli 9.5.0 and node 18, but the same...

Minimum reproduction code

https://github.com/private/code-company

Steps to reproduce

No response

Expected behavior

Well, would be nice to see it starting.

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

No response

NestJS version

9.1.5

Packages versions

{
  "name": "cron-jobs",
  "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\"",
    "lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "test:changed": "jest -o",
    "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": {
    "@nestjs/axios": "2.0.0",
    "@nestjs/bull": "0.6.3",
    "@nestjs/common": "9.1.6",
    "@nestjs/config": "2.2.0",
    "@nestjs/core": "9.1.6",
    "@nestjs/jwt": "9.0.0",
    "@nestjs/mapped-types": "1.2.2",
    "@nestjs/microservices": "9.2.0",
    "@nestjs/mongoose": "9.2.2",
    "@nestjs/passport": "9.0.0",
    "@nestjs/platform-express": "9.1.4",
    "@nestjs/schedule": "2.2.2",
    "@nestjs/swagger": "6.1.2",
    "@nestjs/typeorm": "9.0.1",
    "aws-sdk": "2.1230.0",
    "axios": "1.4.0",
    "bottleneck": "2.19.5",
    "bull": "4.10.0",
    "cache-manager": "4.1.0",
    "cache-manager-ioredis": "2.1.0",
    "class-transformer": "0.5.1",
    "class-validator": "0.14.0",
    "date-fns": "2.29.3",
    "dayjs": "1.11.7",
    "discord-ts-webhook": "1.2.1",
    "express-basic-auth": "1.2.1",
    "kafkajs": "2.2.4",
    "form-data": "4.0.0",
    "lodash": "4.17.21",
    "mongoose": "7.2.0",
    "multer": "2.0.0-rc.4",
    "nestjs-i18n": "~10.2.6",
    "passport": "0.6.0",
    "passport-jwt": "4.0.1",
    "pdfkit": "0.13.0",
    "pg": "8.11.0",
    "redis": "4.3.1",
    "reflect-metadata": "0.1.13",
    "rimraf": "3.0.2",
    "rxjs": "7.5.7",
    "shallow-equal-object": "1.1.1",
    "typeorm": "0.3.16"
  },
  "devDependencies": {
    "@nestjs/cli": "9.1.5",
    "@nestjs/schematics": "9.0.3",
    "@nestjs/testing": "9.1.6",
    "@types/cron": "2.0.1",
    "@types/express": "4.17.17",
    "@types/jest": "29.5.1",
    "@types/cache-manager": "4.0.2",
    "@types/lodash": "4.14.194",
    "@types/multer": "1.4.7",
    "@types/node": "18.15.11",
    "@types/passport-jwt": "3.0.8",
    "@types/pdfkit": "0.12.9",
    "@types/supertest": "2.0.12",
    "@types/uuid": "9.0.1",
    "@typescript-eslint/eslint-plugin": "5.59.1",
    "@typescript-eslint/parser": "5.59.1",
    "eslint": "8.39.0",
    "eslint-config-prettier": "8.8.0",
    "eslint-plugin-prettier": "4.2.1",
    "jest": "29.5.0",
    "prettier": "2.8.8",
    "source-map-support": "0.5.21",
    "supertest": "6.3.3",
    "ts-jest": "29.1.0",
    "ts-loader": "9.4.2",
    "ts-node": "10.9.1",
    "tsconfig-paths": "4.2.0",
    "typescript": "5.0.4"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".*\\.spec\\.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "../coverage",
    "testEnvironment": "node",
    "moduleNameMapper": {
      "^src/(.*)$": "<rootDir>/$1"
    }
  }
}

Node.js version

20.0.2

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@dyonathakramer dyonathakramer added the needs triage This issue has not been looked into label May 24, 2023
@micalevisk
Copy link
Member

micalevisk commented May 24, 2023

hard to tell without some repro, I guess? I've been using the latest version just fine on Linux (node 18)

can you tell us at least when did this error start happening?

@jmcdo29
Copy link
Member

jmcdo29 commented May 24, 2023

This doesn't happen with docker node:latest by the way:

docker run -it node:latest sh -c "npm i -g @nestjs/cli && nest new test-application -p npm && cd test-application && nest start"
added 248 packages in 7s

44 packages are looking for funding
  run `npm fund` for details
npm notice 
npm notice New minor version of npm available! 9.5.0 -> 9.6.7
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.6.7
npm notice Run npm install -g npm@9.6.7 to update!
npm notice 
⚡  We will scaffold your app in a few seconds..

CREATE test-application/.eslintrc.js (663 bytes)
CREATE test-application/.prettierrc (51 bytes)
CREATE test-application/README.md (3340 bytes)
CREATE test-application/nest-cli.json (171 bytes)
CREATE test-application/package.json (1947 bytes)
CREATE test-application/tsconfig.build.json (97 bytes)
CREATE test-application/tsconfig.json (546 bytes)
CREATE test-application/src/app.controller.spec.ts (617 bytes)
CREATE test-application/src/app.controller.ts (274 bytes)
CREATE test-application/src/app.module.ts (249 bytes)
CREATE test-application/src/app.service.ts (142 bytes)
CREATE test-application/src/main.ts (208 bytes)
CREATE test-application/test/app.e2e-spec.ts (630 bytes)
CREATE test-application/test/jest-e2e.json (183 bytes)

✔ Installation in progress... ☕

🚀  Successfully created project test-application
👉  Get started with the following commands:

$ cd test-application
$ npm run start

                                                                                                                                          
                                                                                                                           Thanks for installing Nest 🙏
                                                                                                                  Please consider donating to our open collective
                                                                                                                         to help us maintain this package.
                                                                                                                                          
                                                                                                                                          
                                                                                                                🍷  Donate: https://opencollective.com/nest
                                                                                                                                          
[Nest] 94  - 05/24/2023, 8:59:43 PM     LOG [NestFactory] Starting Nest application...
[Nest] 94  - 05/24/2023, 8:59:43 PM     LOG [InstanceLoader] AppModule dependencies initialized +10ms
[Nest] 94  - 05/24/2023, 8:59:43 PM     LOG [RoutesResolver] AppController {/}: +8ms
[Nest] 94  - 05/24/2023, 8:59:43 PM     LOG [RouterExplorer] Mapped {/, GET} route +2ms
[Nest] 94  - 05/24/2023, 8:59:43 PM     LOG [NestApplication] Nest application successfully started +2ms

@dmitriybo
Copy link

dmitriybo commented May 25, 2023

The thing is that if there is a dependency in the project that uses the glob package, then a conflict may arise. It requires the jackspeak package, which in turn uses the @isaacs/cliui package, which recently upgraded to 8.0.2 and started using wrap-ansi@8.1.0. The glob package is a dependency of many other packages, such as graphql-ws (which @nest/graphql needs).
Therefore, it is required to update the inquirer package to the latest version. This is part of issue #1313.
As a temporary solution, you can write in package.json:

"resolutions": {
  "wrap-ansi": "7.0.0",
  "string-width": "4.1.0"
}

@jmcdo29
Copy link
Member

jmcdo29 commented May 25, 2023

See. All that above, that's why we all for reproductions.

@dmitriybo
Copy link

dmitriybo commented May 25, 2023

Pretty strange behavior of yarn (using the latest version 1.22.19):

npm i -g @nestjs/cli
nest new project-name (select yarn)

Next, I install packages that have wrap-ansi in the dependency tree, while installing them individually:
yarn add rimraf
yarn add glob
An error occurs.

const wrapAnsi = require('wrap-ansi');
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\user\project\node_modules\wrap-ansi\index.js from C:\Users\user\project\node_modules\inquirer\lib\utils\screen-manager.js not supported. 
Instead change the require of index.js in C:\Users\user\project\node_modules\inquirer\lib\utils\screen-manager.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (C:\Users\user\project\node_modules\inquirer\lib\utils\screen-manager.js:4:18)

But if you delete the node_modules folder and reinstall the packages, then everything is fine.

@kamilmysliwiec
Copy link
Member

This doesn't seem to be related specifically to NestJS.

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.

@nestjs nestjs locked and limited conversation to collaborators May 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

5 participants