strapi / starters-and-templates

Monorepo for all official Strapi v4 templates
MIT License
327 stars 117 forks source link

DB Data Not Imported #67

Open BenGreyTwo opened 1 year ago

BenGreyTwo commented 1 year ago

When running npx create-strapi-app my-app-name --template corporate and going through the manual setup, the data to build the starter site is not imported into the DB. The tables are created but not populated.

I've tried on several node + npm versions node: v16.18.1 npm: 8.19.2

subaquatic-pierre commented 1 year ago

I can confirm the same issue with blog template. running npx create-strapi-app my-app-name --template blog, does not bootstrap the app with any data. Tried with both node v16 and v18

NeseemGit commented 1 year ago

Same issue here. The data does not get populated. I don't know the root cause but it seems to be related to the Strapi version. The data does populate in v4.2 but not 4.5.

In addition, when adding the data manually, the homepage slug in the corporate starter codebase is expecting an empty string "" but when adding pages in the GUI, a blank value get set as null in the DB which will load a 404 for the homepage.

subaquatic-pierre commented 1 year ago

It seems like the CLI is not pulling the template from the correct repo perhaps. I copied the contents from this folder https://github.com/strapi/starters-and-templates/tree/main/packages/templates/blog/template into a newly created project, I'm sure it will work for corporate as well. Running npx strapi develop the first time populates the data. It is a workaround for me for now.

webhype commented 1 year ago

Here's the ugliest hackiest workaround (this is on Mac OS Ventura). You have to trick the starter installer to download and execute Strapi v4.4.7 instead of v4.5.5. Why 4.4.7? Because I have determined through trial and error that template importing broke as of version 4.5.0. πŸ˜€

cd /usr/local/bin
ls -alt create-strapi*

Verify that from your previous failed attempts, there's a symlink that looks like this:

create-strapi-starter -> ../../../Users/macuser/.config/yarn/global/node_modules/.bin/create-strapi-starter

Rename the symlink to create-strapi-starter@4.4.7 like so:

mv create-strapi-starter create-strapi-starter@4.4.7

Due to a bug (?) in the strapi-starter and strapi-template scripts, it can download an older version of Strapi by specifying something like @4.4.7 but it can't launch it because it expects the name of the symlink to end in @4.4.7 as well. Renaming the symlink to the name that the script expects helps it to launch it.

Now go back into your working directory, let's say ~, and create your app, this time specifying @4.4.7 as Strapi version:

cd ~
yarn create strapi-starter@4.4.7 my-app next-corporate

It should download the 4.4.7 code and populate the database, images, etc. more or less correctly. It should launch frontend (Next.js app) and backend (Strapi app) with a Project Information box like this (note Strapi 4.4.7):

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Time               β”‚ Tue Jan 03 2023 08:43:05 GMT-0500 (Eastern Stan… β”‚
β”‚ Launched in        β”‚ 5789 ms                                          β”‚
β”‚ Environment        β”‚ development                                      β”‚
β”‚ Process PID        β”‚ 57583                                            β”‚
β”‚ Version            β”‚ 4.4.7 (node v16.19.0)                            β”‚
β”‚ Edition            β”‚ Community                                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Log in at http://localhost:1337/admin and verify that the Global object is populated, and that there are four Pages objects of which 3 are published. https://localhost:3000/ should load with a few small complaints, but should not WSOD or throw an error.

Now migrate to Strapi back-end current version (v4.5.5 as of this writing), as per the migration guides.

sntxerror commented 1 year ago

The problem reproduces with TS projects with latest starter

boottrap.js doesn't builds to dist folder.

I've followed this official guide https://docs.strapi.io/dev-docs/typescript#add-typescript-support-to-an-existing-strapi-project

fixed imports and everything works!