SAP / spartacus

Spartacus is a lean, Angular-based JavaScript storefront for SAP Commerce Cloud that communicates exclusively through the Commerce REST API.
Apache License 2.0
738 stars 383 forks source link

App does not start when installed from the libs #740

Closed plabadie closed 5 years ago

plabadie commented 5 years ago

After following the installation procedure, I get build errors when I attempt to launch the storefront with ng serve:

ERROR in node_modules/@spartacus/core/src/product/store/effects/product.effect.d.ts(10,19): error TS2307: Cannot find module '../../../../../../../../../../SAPDevelop/spartacus/dev/2-spartacus/node_modules/rxjs/internal/Observable'.
node_modules/@spartacus/core/src/state/utils/loader/loader.helpers.d.ts(2,59): error TS2307: Cannot find module '../../../../../../../../../../SAPDevelop/spartacus/dev/2-spartacus/node_modules/rxjs/internal/types'.
node_modules/@spartacus/core/src/state/utils/loader/loader.helpers.d.ts(3,59): error TS2307: Cannot find module '../../../../../../../../../../SAPDevelop/spartacus/dev/2-spartacus/node_modules/rxjs/internal/types'.
node_modules/@spartacus/core/src/state/utils/loader/loader.helpers.d.ts(4,62): error TS2307: Cannot find module '../../../../../../../../../../SAPDevelop/spartacus/dev/2-spartacus/node_modules/rxjs/internal/types'.

ℹ 「wdm」: Failed to compile.

To repro, follow the installation instructions: https://github.com/SAP/cloud-commerce-spartacus-storefront/blob/develop/docs/setupandinstallation.md

...with the exception that you must use locally built libs for "@spartacus".

LTiger14 commented 5 years ago

This could be a cause of the first one but it seems you have an error in styles.css. In our install guide we tell users to create their shell app with scss as styles preprocessor. Therefore, the import of the styles lib should be in styles.scss.

Also, the error says Can't resolve '@spartacus/styles/index'. This should be ~@spartacus/styles/index.

plabadie commented 5 years ago

You are right. css is not good. It should have been scss. The error is due to a human error on my part. Our setup instructions are clear on that point. I omitted the --style=scss flag in the command I used to create the storefront app, which should be for example ng new mystore --style=scss.

I reinstalled spartacus manually using the --style=scss and as expected the error is gone. I removed the storefrontstyles error from the issue description to avoid confusion.

The other errors remains. Which is now consistent with the results I get from the installation script

hackergil commented 5 years ago

This problem was the same we had last sprint, where some members don't have an explicit type (see above) and typescript is compiled, the compiler tries to infer the type and adds a relative path from where to import the type, which includes the absolute path of the import.

The solution is to add the types explicitly and the imports (see commit above). This is a typescript 2.x problem and it should be gone once we upgrade to typescript 3.

This fix is in our release branch so there's no PR for it. It will be merged when we merge the release branch.