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

Unable to run application after install @nestjs/platform-express #13298

Closed
5 of 15 tasks
vfxproForex opened this issue Mar 6, 2024 · 3 comments
Closed
5 of 15 tasks

Unable to run application after install @nestjs/platform-express #13298

vfxproForex opened this issue Mar 6, 2024 · 3 comments
Labels
needs triage This issue has not been looked into

Comments

@vfxproForex
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

After installing the package and rerun yarn start:dev, the will refuse to start and output the following: const stringWidth = require('string-width');

the full output is the following:

$ nest start --watch --reset-cache
/Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/wrap-ansi/index.js:2
const stringWidth = require('string-width');
                    ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/string-width/index.js from /Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/wrap-ansi/index.js not supported.
Instead change the require of /Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/string-width/index.js in /Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/wrap-ansi/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/wrap-ansi/index.js:2:21)
    at Object.<anonymous> (/Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/inquirer/lib/utils/screen-manager.js:4:18)
    at Object.<anonymous> (/Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/inquirer/lib/prompts/base.js:14:23)
    at Object.<anonymous> (/Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/inquirer/lib/prompts/list.js:11:14)
    at promptModule.restoreDefaultPrompts (/Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/inquirer/lib/inquirer.js:61:33)
    at inquirer.createPromptModule (/Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/inquirer/lib/inquirer.js:72:16)
    at Object.<anonymous> (/Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/inquirer/lib/inquirer.js:84:28)
    at Object.<anonymous> (/Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/@nestjs/cli/lib/utils/project-utils.js:4:18)
    at Object.<anonymous> (/Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/@nestjs/cli/actions/generate.action.js:9:25)
    at Object.<anonymous> (/Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/@nestjs/cli/actions/index.js:19:14)
    at Object.<anonymous> (/Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/@nestjs/cli/commands/command.loader.js:5:19)
    at Object.<anonymous> (/Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/@nestjs/cli/commands/index.js:17:14)
    at Object.<anonymous> (/Users/tony/workspace/freelance/kurisani/server-app/ftx-server/node_modules/@nestjs/cli/bin/nest.js:5:20) {
  code: 'ERR_REQUIRE_ESM'
}

Minimum reproduction code

git@github.com:vfxproForex/ftx-server.git

Steps to reproduce

  1. npx nestjs new test-app
  2. yarn add @nestjs/platform-express express express-session
  3. yarn add -D @types/express @types/express-session
  4. yarn start:dev

Expected behavior

The server is expected to run normally

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

non

NestJS version

10.0.0

Packages versions

  "dependencies": {
    "@apollo/server": "^4.10.0",
    "@as-integrations/fastify": "^2.1.1",
    "@fastify/secure-session": "^7.1.0",
    "@nestjs-modules/mailer": "^1.11.0",
    "@nestjs/apollo": "^12.1.0",
    "@nestjs/common": "^10.0.0",
    "@nestjs/config": "^3.2.0",
    "@nestjs/core": "^10.0.0",
    "@nestjs/graphql": "^12.1.1",
    "@nestjs/microservices": "^10.3.3",
    "@nestjs/mongoose": "^10.0.4",
    "@nestjs/platform-express": "^10.3.3",
    "@nestjs/platform-fastify": "^10.3.3",
    "bcryptjs": "^2.4.3",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.14.1",
    "connect-redis": "^7.1.1",
    "cookie-parser": "^1.4.6",
    "cors": "^2.8.5",
    "express": "^4.18.2",
    "express-session": "^1.18.0",
    "fastify": "^4.26.1",
    "graphql": "^16.8.1",
    "graphql-tools": "^9.0.1",
    "ioredis": "^5.3.2",
    "mongodb": "^6.3.0",
    "mongoose": "^8.2.0",
    "nodemailer": "^6.9.10",
    "reflect-metadata": "^0.2.0",
    "rxjs": "^7.8.1",
    "uuid": "^9.0.1"
  },


Node.js version

20.9.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

sdsd

@vfxproForex vfxproForex added the needs triage This issue has not been looked into label Mar 6, 2024
@micalevisk
Copy link
Member

micalevisk commented Mar 6, 2024

I believe that you just need to remove the lock file and install everything again

Also, instead of using nest globally, I'd suggest you to use it once like this: npx @nestjs/cli new and then use the local one (yarn nest generate ...)

@Tony133
Copy link
Contributor

Tony133 commented Mar 6, 2024

I too have had the same problem these weeks working with yarn.
The problem, from what I understand, is yarn, removing the yarn.lock file and doing the yarn installation should solve it. it also happens with projects already created after downloading a repository and doing the yarn installation.

With pnpm this problem does not occur even with versions of yarn higher than v1.22.21, I think it is a problem with 1.22.21.

@vfxproForex
Copy link
Author

I jsut tried the solution and i can also confirm that yarn is the problem

@micalevisk micalevisk closed this as not planned Won't fix, can't repro, duplicate, stale Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

3 participants