Responses to the discussion on Github
Author
update, I changed the server.js file for this :
module.exports = ({ env }) => ({
host: env("HOST", "0.0.0.0"),
port: env.int("PORT", 1337),
url: "http://strapi.live-for-good.org:1337",
admin: {
autoOpen: false,
url: "/admin",
},
});
Now, I got this url :
To access the server ⚡️, go to:
http://strapi.live-for-good.org:1337
I can go to strapi.live-for-good.org:1337, but when I go to the http://strapi.live-for-good.org:1337/admin, it does not work, I only have a blank page and this logs :
debug GET /admin (0 ms) 200
debug GET /strapi.live-for-good.org/admin/runtime~main.5cc67eba.js (1 ms) 404
debug GET /strapi.live-for-good.org/admin/main.d6814a6d.chunk.js (1 ms) 404
Does anybody have an idea ? 
Have you rebuilt your admin page? by issuing npm run build
. ?
Author
Hi !
Thank you for your answer @divineforge
I change the file again :
module.exports = ({ env }) => ({
host: env("HOST", "0.0.0.0"),
port: env.int("PORT", 1337),
url: "http://strapi.live-for-good.org:1337",
admin: {
autoOpen: false,
},
});
And I rebuilt the admin page, it works now !
But, still have a problem with pm2
I got this log :
Error: Cannot find module '/home/lfg/new_strapi/strapi-gatsby-stable'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
at Function.Module._load (internal/modules/cjs/loader.js:840:27)
at Object.<anonymous> (/home/lfg/.nvm/versions/node/v12.16.3/lib/node_modules/pm2/lib/ProcessContainerFork.js:32:23)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
It’s weird, because I did my npm install
, npm run build
, I can launch npm run develop
, but cannot run it with pm2 
An idea ?
could you show your pm2 configuration?
chance are pm2 configuration were not set correctly… e.g.
an idea is: in pm2 script
would be something like ‘npm’, and args
would be ‘start’. … then you put in the correct variable in it. it should make use of the npm start in your package.json resolve for strapi modules.
Author
Hi !
I succeed to solve my issue about pm2, the problem was that I was trying to launch pm2 from an other folder… so stupid ><
I still have a migration problem.
I used the migration script to update my mongodb database, it print me “true” at the end of the migration.
But, when I login me in with strapi, I see that that I still have all my images in the media library, but it does not match with my types 
I can link them again one by one, but is there a better way ?
Thank you and have a good day
No very sure about the situation.
Maybe you may consider some scripting to update it.? 
Author
Hi divineforge,
I will try to be more clear 
In my elements, I loose the link between a media and my type, like on this screen :

I do not want to manage them one by one, I have more than 400 images x)
I already run this script :
var models = {
Accueil: {
collection: "accueils",
files: {},
},
BandeauChiffre: {
collection: "bandeau_chiffres",
files: {},
},
............
};
for (var i in models) {
var model = models[i];
var update = {};
var keyCount = 0;
for (var key in model.files) {
keyCount += 1;
update[key] = '';
}
if (keyCount > 0) {
db.getCollection(model.collection).update({}, { $unset: update }, { multi: true });
}
}
var fileCursor = db.getCollection('upload_file').find({});
while (fileCursor.hasNext()) {
var el = fileCursor.next();
el.related.forEach(function(fileRef) {
var model = models[fileRef.kind];
if (!model) {
return;
}
var fieldType = model.files && model.files[fileRef.field];
// stop if the file points to a field the user didn't specify
if (!fieldType) {
return;
}
if (fieldType === 'single') {
db.getCollection(model.collection).updateOne(
{ _id: fileRef.ref },
{ $set: { [fileRef.field]: el._id } }
);
} else if (fieldType === 'multiple') {
db.getCollection(model.collection).updateOne(
{ _id: fileRef.ref },
{ $push: { [fileRef.field]: el._id } }
);
}
});
}
I don’t know what I can do more 
is this script really as what it is?
var models = {
Accueil: {
collection: "accueils",
files: {},
},
BandeauChiffre: {
collection: "bandeau_chiffres",
files: {},
},
the files:{} are blank
?
it’s not referring to the image and image type either. You’re referring to this documentation here: https://strapi.io/documentation/v3.x/migration-guide/migration-guide-beta.19-to-beta.20.html ?
The suggested format would be as below:
var models = {
ModelName: {
collection: 'collectionName',
files: {
image: 'single',
images: 'multiple',
},
},
};
// rest of the script
Author
Yes, I’m referring to this doc.
I didn’t put all the model, and I did not choose the good example, sorry.
Another example of my model is :
ComponentAtoutsListe: {
collection: "components_atouts_listes",
files: {
icone: "single",
},
},
It look likes ok, isn’t it ?
files.icone ? not sure if this actually recognized by Strapi. From what I read… it’s either image
or images
from the above guide.
Author
Actually I don’t know, I think it’s just the name of the field, I show you the full models.json file :
{
"Accueil": {
"collection": "accueils",
"files": {}
},
"BandeauChiffre": {
"collection": "bandeau_chiffres",
"files": {}
},
"Calendrier": {
"collection": "calendriers",
"files": {}
},
"Coach": {
"collection": "coaches",
"files": {
"leftImage": "single",
"rightImage": "single"
}
},
"Communaute": {
"collection": "communaute",
"files": {
"Image": "single"
}
},
"IlsNousSoutiennent": {
"collection": "ils_nous_soutiennents",
"files": {}
},
"LaPlateforme": {
"collection": "la_plateformes",
"files": {}
},
"LastCall": {
"collection": "last_calls",
"files": {}
},
"LeCampus": {
"collection": "le_campuses",
"files": {
"legendeImage": "single"
}
},
"LeProgramme": {
"collection": "le_programmes",
"files": {}
},
"LesAlumnis": {
"collection": "les_alumnis",
"files": {}
},
"LivreBlanc": {
"collection": "livre_blancs",
"files": {}
},
"ProjetAlumni": {
"collection": "projet_alumni",
"files": {}
},
"UploadFile": {
"collection": "upload_file",
"files": {}
},
"UsersPermissionsPermission": {
"collection": "users-permissions_permission",
"files": {}
},
"UsersPermissionsRole": {
"collection": "users-permissions_role",
"files": {}
},
"UsersPermissionsUser": {
"collection": "users-permissions_user",
"files": {}
},
"ComponentAlumnisAlumnis": {
"collection": "components_alumnis_alumnis",
"files": {
"image": "single"
}
},
"ComponentAtoutsListe": {
"collection": "components_atouts_listes",
"files": {
"icone": "single"
}
},
"ComponentCalendarElementscalendrier": {
"collection": "components_calendar_elementscalendriers",
"files": {
"image": "single"
}
},
"ComponentPlateformePlateformeArticles": {
"collection": "components_plateforme_plateforme_articles",
"files": {
"image": "single"
}
},
"ComponentProjetProjet": {
"collection": "components_projet_projets",
"files": {
"imageCouverture": "single",
"imageProfil": "single"
}
},
"ComponentSliderImages": {
"collection": "components_slider_images",
"files": {
"image": "single"
}
},
"ComponentSliderProjet": {
"collection": "components_slider_projets",
"files": {
"imageDeCouverture": "single",
"imageDeProfil": "single"
}
},
"ComponentSliderSlider": {
"collection": "components_slider_sliders",
"files": {
"image": "single"
}
},
"ComponentValeurValeurs": {
"collection": "components_valeur_valeurs",
"files": {}
}
}
looks like you’re right.
The model.json that was generated based on the script export.js
, inside the files are the field name.
I guess I don’t have any further clue on this migration.
Perhaps just one last thing is to examine what’s in your mongodb, after you executed the ‘finalized script’ in MongoDB shell. you might want to do a bit of debugging of the data in the database, compare it with the file name, or the path to your media library.
Some debugging steps would be:
1- manually insert an image via Strapi admin. link them manually.
2- then compare the values; what was changed in the database? or what was changed in the code? hopefully, from there you found the relationship.
Author
Hi !
Sorry for the delay.
I decided to update my 90 images one by one, it takes me 1 hour of stupid work but it works now
Thank you @divineforge for your help, I hope to not have this problem again x)
Have a good day !
welcome
glad it works for you.