node version: v10.14.0
npm version: 6.9.0
@loopback/cli version: 1.8.2
@loopback/* dependencies:
- @loopback/authentication: ^1.0.15
- @loopback/boot: ^1.1.0
- @loopback/build: ^1.3.2
- @loopback/context: ^1.7.0
- @loopback/core: ^1.1.8
- @loopback/metadata: ^1.0.8
- @loopback/openapi-spec-builder: ^1.1.0
- @loopback/openapi-v3-types: ^1.0.8
- @loopback/openapi-v3: ^1.3.0
- @loopback/repository-json-schema: ^1.3.4
- @loopback/repository: ^1.1.8
- @loopback/rest: ^1.8.0
- @loopback/testlab: ^1.1.0
- @loopback/docs: ^1.10.0
- @loopback/example-hello-world: ^1.1.6
- @loopback/example-log-extension: ^1.1.6
- @loopback/example-rpc-server: ^1.1.5
- @loopback/example-todo: ^1.5.1
- @loopback/example-soap-calculator: ^1.4.1
- @loopback/service-proxy: ^1.0.10
- @loopback/http-caching-proxy: ^1.0.9
- @loopback/http-server: ^1.1.8
- @loopback/example-todo-list: ^1.5.1
- @loopback/dist-util: ^0.4.0
- @loopback/rest-explorer: ^1.1.11
- @loopback/tslint-config: ^2.0.2
- @loopback/example-express-composition: ^1.2.1
Following official tutorial https://v4.loopback.io/getting-started.html but application won't start when entering npm start.
Follow steps to install loopback 4 and create application.
Use all defaults options as is.
When entering npm start, build is complaining with following output.
npm start
> [email protected] prestart /Users/GUL/Documents/Missions/BetaGouv/trait-d-union-backoffice/trait-d-union
> npm run build
> [email protected] build /Users/GUL/Documents/Missions/BetaGouv/trait-d-union-backoffice/trait-d-union
> lb-tsc es2017 --outDir dist
../node_modules/@types/jest/index.d.ts:27:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'beforeEach' must be of type 'HookFunction', but here has type 'Lifecycle'.
27 declare var beforeEach: jest.Lifecycle;
~~~~~~~~~~
../node_modules/@types/jest/index.d.ts:29:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'afterEach' must be of type 'HookFunction', but here has type 'Lifecycle'.
29 declare var afterEach: jest.Lifecycle;
~~~~~~~~~
../node_modules/@types/jest/index.d.ts:30:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'describe' must be of type 'SuiteFunction', but here has type 'Describe'.
30 declare var describe: jest.Describe;
~~~~~~~~
../node_modules/@types/jest/index.d.ts:32:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'xdescribe' must be of type 'PendingSuiteFunction', but here has type 'Describe'.
32 declare var xdescribe: jest.Describe;
~~~~~~~~~
../node_modules/@types/jest/index.d.ts:33:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'it' must be of type 'TestFunction', but here has type 'It'.
33 declare var it: jest.It;
~~
../node_modules/@types/jest/index.d.ts:35:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'xit' must be of type 'PendingTestFunction', but here has type 'It'.
35 declare var xit: jest.It;
~~~
../node_modules/@types/jest/index.d.ts:36:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'test' must be of type 'TestFunction', but here has type 'It'.
36 declare var test: jest.It;
~~~~
node_modules/@types/node/module.d.ts:2:5 - error TS2300: Duplicate identifier 'mod'.
2 export = NodeJS.Module;
~~~~~~~~~~~~~~~~~~~~~~~
../../../../../node_modules/@types/requirejs/index.d.ts:38:11
38 export = mod;
~~~
'mod' was also declared here.
../../../../../node_modules/@types/requirejs/index.d.ts:38:11 - error TS2300: Duplicate identifier 'mod'.
38 export = mod;
~~~
node_modules/@types/node/module.d.ts:2:5
2 export = NodeJS.Module;
~~~~~~~~~~~~~~~~~~~~~~~
'mod' was also declared here.
../../../../../node_modules/@types/requirejs/index.d.ts:422:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'require' must be of type 'NodeRequire', but here has type 'Require'.
422 declare var require: Require;
~~~~~~~
Found 10 errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `lb-tsc es2017 --outDir dist`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/GUL/.npm/_logs/2019-03-18T21_22_06_184Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] prestart: `npm run build`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] prestart script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/GUL/.npm/_logs/2019-03-18T21_22_06_203Z-debug.log
Follow steps to install loopback 4 and create application.
Use all defaults options as is.
When entering npm start, output shows no error and application is launched.
@HEYGUL, I just tried it the getting started instructions and it's working fine for me. For your case, it looks like some of the required dependencies are not installed. Could you please run lb4 app with ---yes option so that it will automatically accept all defaults without prompting you? i.e.
lb4 app <your app name> --yes
Then we can compare what was missing. Thanks.
@dhmlau thank you for your answer.
lb4 app trait-d-union-backend --yes
gave me this output
create .mocharc.json
create .npmrc
create .prettierignore
create .prettierrc
create DEVELOPING.md
create README.md
create index.ts
create package.json
create tsconfig.json
create tslint.build.json
create tslint.json
create .vscode/settings.json
create .vscode/tasks.json
create .gitignore
create .dockerignore
create Dockerfile
create index.js
create public/index.html
create src/application.ts
create src/index.ts
create src/migrate.ts
create src/sequence.ts
create src/__tests__/README.md
create src/controllers/README.md
create src/controllers/index.ts
create src/controllers/ping.controller.ts
create src/datasources/README.md
create src/models/README.md
create src/repositories/README.md
create src/__tests__/acceptance/home-page.acceptance.ts
create src/__tests__/acceptance/ping.controller.acceptance.ts
create src/__tests__/acceptance/test-helper.ts
npm WARN deprecated @types/[email protected]: This is a stub types definition. handlebars provides its own type definitions, so you do not need this installed.
npm WARN [email protected] No license field.
added 682 packages from 1475 contributors and audited 4603 packages in 9.228s
found 2 vulnerabilities (1 low, 1 moderate)
run `npm audit fix` to fix them, or `npm audit` for details
Application trait-d-union-backend was created in trait-d-union-backend.
Next steps:
$ cd trait-d-union-backend
$ npm start
I then followed next steps:
cd trait-d-union-backend
nom start
and I still have the same issue:
> [email protected] prestart /Users/GUL/Documents/Missions/BetaGouv/trait-d-union-backend
> npm run build
> [email protected] build /Users/GUL/Documents/Missions/BetaGouv/trait-d-union-backend
> lb-tsc es2017 --outDir dist
node_modules/@types/node/module.d.ts:2:5 - error TS2300: Duplicate identifier 'mod'.
2 export = NodeJS.Module;
~~~~~~~~~~~~~~~~~~~~~~~
../../../../node_modules/@types/requirejs/index.d.ts:38:11
38 export = mod;
~~~
'mod' was also declared here.
../../../../node_modules/@types/requirejs/index.d.ts:38:11 - error TS2300: Duplicate identifier 'mod'.
38 export = mod;
~~~
node_modules/@types/node/module.d.ts:2:5
2 export = NodeJS.Module;
~~~~~~~~~~~~~~~~~~~~~~~
'mod' was also declared here.
../../../../node_modules/@types/requirejs/index.d.ts:422:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'require' must be of type 'NodeRequire', but here has type 'Require'.
422 declare var require: Require;
~~~~~~~
Found 3 errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `lb-tsc es2017 --outDir dist`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/GUL/.npm/_logs/2019-03-19T08_37_14_379Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] prestart: `npm run build`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] prestart script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/GUL/.npm/_logs/2019-03-19T08_37_14_424Z-debug.log
@strongloop/loopback-maintainers, any ideas on why this occurred?
I tried with the same Node.js version and @loopback/cli version and couldn't reproduce the problem. There's a similar error mentioned in https://github.com/rollup/rollup/issues/2142 but it doesn't explain why it works for me but not @HEYGUL.
Thanks!
I don't see @types/requirejs locally. Can you run npm ls @types/requirejs to see where it's from?
Did you create the project inside a path that might have node_modules in its parent directories?
npm ls @types/requirejs gives following output
[email protected] /Users/GUL/Documents/Missions/BetaGouv/trait-d-union-backend
└── (empty)
I will dig to find if any node_modules is present in a parent directory.
Spotted! I did find a node_modules in parent path (in my home directory itself)
Deleting it fixed the issue.
Thank you very much for the fast and effective support!
It doesn't work for me.
Solution: https://github.com/strongloop/loopback-next/issues/2751#issuecomment-549491143
Did you check https://github.com/strongloop/loopback-next/issues/2611#issuecomment-474778975?
@pSnehanshu What are the exact steps to reproduce the issue? lb4 app trait-d-union-backend --yes works for me on Mac.
@raymondfeng Yes, I checked that comment, not applicable in my case.
I tried lb4 app, then filled up the form, and then this error occurs. I then deleted the node_modules folder inside the project directory and then run npm install, the error occurred again.
Then I did this https://github.com/strongloop/loopback-next/issues/2751#issuecomment-549491143, and it worked!
Most helpful comment
Spotted! I did find a
node_modulesin parent path (in my home directory itself)Deleting it fixed the issue.
Thank you very much for the fast and effective support!