loopbackio / loopback-next

LoopBack makes it easy to build modern API applications that require complex integrations.
https://loopback.io
Other
4.88k stars 1.06k forks source link

lb4 app Command failing on windows OS #8247

Open Ismail-dev opened 2 years ago

Ismail-dev commented 2 years ago

Describe the bug

As a developer I want to quickly scaffold an application. For this I'm using getting started docs https://loopback.io/doc/en/lb4/Getting-started.html

Installed node.js version 17.3.1 and loopback4 cli too npm i -g @loopback/cli

When I run the lb4 app command and provide the details in the CLI, the application scaffolding fails. Tried with all features, no features and selected features too. Didn't worked.

By features I mean image

CLI used are gitbash, windows CMD, vscode Terminal [ did not worked in any of the CLI too]

Logs

D:\projects\test-projects\loopBack4>lb4 app
? Project name: blog
? Project description: blog application
? Project root directory: blog
? Application class name: BlogApplication
? Select features to enable in the project Enable eslint, Enable prettier, Enable mocha, Enable loopbackBuild, Enable vscode, Enable docker, Enable repositories, Enable services
node:events:368
      throw er; // Unhandled 'error' event
      ^

Error: ENOENT: no such file or directory, scandir 'D:\projects\test-projects\loopBack4\blog\_.gitignore'
    at Object.readdirSync (node:fs:1392:3)
    at exports.readdir (C:\Users\sekh.ismail\nvm\v17.3.1\node_modules\@loopback\cli\node_modules\@mrmlnc\readdir-enhanced\lib\sync\fs.js:18:20)
    at Object.safeCall [as safe] (C:\Users\sekh.ismail\nvm\v17.3.1\node_modules\@loopback\cli\node_modules\@mrmlnc\readdir-enhanced\lib\call.js:24:8)
    at DirectoryReader.readNextDirectory (C:\Users\sekh.ismail\nvm\v17.3.1\node_modules\@loopback\cli\node_modules\@mrmlnc\readdir-enhanced\lib\directory-reader.js:78:10)
    at Readable.DirectoryReader.stream._read (C:\Users\sekh.ismail\nvm\v17.3.1\node_modules\@loopback\cli\node_modules\@mrmlnc\readdir-enhanced\lib\directory-reader.js:57:18)
    at Readable.read (node:internal/streams/readable:496:27)
    at readdirSync (C:\Users\sekh.ismail\nvm\v17.3.1\node_modules\@loopback\cli\node_modules\@mrmlnc\readdir-enhanced\lib\sync\index.js:27:21)
    at Function.readdirSyncStat (C:\Users\sekh.ismail\nvm\v17.3.1\node_modules\@loopback\cli\node_modules\@mrmlnc\readdir-enhanced\lib\index.js:34:10)
    at ReaderSync.dynamicApi (C:\Users\sekh.ismail\nvm\v17.3.1\node_modules\@loopback\cli\node_modules\yeoman-generator\node_modules\fast-glob\out\providers\reader-sync.js:64:24)
    at ReaderSync.api (C:\Users\sekh.ismail\nvm\v17.3.1\node_modules\@loopback\cli\node_modules\yeoman-generator\node_modules\fast-glob\out\providers\reader-sync.js:56:25)
Emitted 'error' event on Readable instance at:
    at emitErrorNT (node:internal/streams/destroy:164:8)
    at emitErrorCloseNT (node:internal/streams/destroy:129:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4058,
  syscall: 'scandir',
  code: 'ENOENT',
  path: 'D:\\projects\\test-projects\\loopBack4\\blog\\_.gitignore'
}

Node.js v17.3.1

Additional information

With all features selected image

With selected features image

Without any features image

Reproduction

open a cli and follow the steps on a windows 10 machine Install node.js then Install LoopBack 4 CLI run lb4 app command

kpostekk commented 2 years ago

I can confirm it's not only windows issue. I have the same bug on macOS. Screenshot 2022-01-18 at 22 38 17

kpostekk commented 2 years ago

@Ismail-dev i think the issue caused by node version. I have reinstalled node to node 16 using nvm and everything works fine.

Ismail-dev commented 2 years ago

@kpostekk Yes, looks like it works with node 16 with some errors logged

image

dhmlau commented 2 years ago

@Ismail-dev, I was also having issue to create a LB4 app using Node.js 17.x, but was working fine with Node.js 16.x.

Regarding the "could not resolve dependency" issue, if you run npm install in the newly created project, would it work? I also found https://stackoverflow.com/questions/64573177/unable-to-resolve-dependency-tree-error-when-installing-npm-packages, it suggests to run npm install --legacy-peer-deps. Hope it helps.

Kayra commented 1 year ago

Still running into this issue:

MacOS 12.4 node: v18.9.0 (npm v9.1.2)

Ran command: lb4 app

Stacktrace (same error with all features enabled):

? Select features to enable in the project Enable mocha, Enable loopbackBuild, Enable docker, Enable repositories, Enable services
? Yarn is available. Do you prefer to use it by default? No
    force todo-list/.yo-rc.json
   create todo-list/.mocharc.json
   create todo-list/DEVELOPING.md
   create todo-list/package.json
   create todo-list/tsconfig.json
   create todo-list/.gitignore
   create todo-list/.dockerignore
   create todo-list/Dockerfile
   create todo-list/README.md
   create todo-list/public/index.html
   create todo-list/src/application.ts
   create todo-list/src/index.ts
   create todo-list/src/migrate.ts
   create todo-list/src/openapi-spec.ts
   create todo-list/src/sequence.ts
   create todo-list/src/__tests__/README.md
   create todo-list/src/controllers/README.md
   create todo-list/src/controllers/index.ts
   create todo-list/src/controllers/ping.controller.ts
   create todo-list/src/datasources/README.md
   create todo-list/src/models/README.md
   create todo-list/src/repositories/README.md
   create todo-list/src/__tests__/acceptance/home-page.acceptance.ts
   create todo-list/src/__tests__/acceptance/ping.controller.acceptance.ts
   create todo-list/src/__tests__/acceptance/test-helper.ts

No change to package.json was detected. No package manager install will be executed.
npm WARN config cache-min This option has been deprecated in favor of `--prefer-offline`.
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @loopback/eslint-config@13.0.6
npm WARN Found: eslint@undefined
npm WARN node_modules/eslint
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint@"^8.28.0" from @loopback/eslint-config@13.0.6
npm WARN node_modules/@loopback/eslint-config
npm WARN   @loopback/eslint-config@"^13.0.6" from @loopback/build@9.0.6
npm WARN   node_modules/@loopback/build
npm ERR! code ETARGET
npm ERR! notarget No matching version found for @types/node@^14.18.34.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/kayra/.npm/_logs/2022-12-22T00_43_38_066Z-debug-0.log

Using node v16 didn't work for me. Running npm install --legacy-peer-deps in the project after creation did work for me.