Tom
Tom

Reputation: 43

Deploying Strapi to Plesk - strapi not found

I want to deploy strapi to a server managed with plesk. I installed strapi in cli. Strapi itself also runs there but says that i should visit localhost:1337/admin

In Plesk a startup-file is needed. Strapi suggests a server.js with 2 lines of code in it

const strapi = require('strapi');

strapi(/* {...} */).start();

however, i exactly this. When i hit the NPM install button it also resolves everything without any problem. If i want to reach my site i get a error from Phusion Passenger

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'strapi'
Require stack:
- /var/www/vhosts/frosty-goldstine.82-165-106-228.plesk.page/strapi/server.js
- /usr/share/passenger/helper-scripts/node-loader.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at Module.require (/usr/share/passenger/helper-scripts/node-loader.js:80:25)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/var/www/vhosts/frosty-goldstine.82-165-106-228.plesk.page/strapi/server.js:1:16)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/var/www/vhosts/frosty-goldstine.82-165-106-228.plesk.page/strapi/server.js',
    '/usr/share/passenger/helper-scripts/node-loader.js'
  ]
}

How is it possible, that strapi is unknown? And how can i resolve?

Upvotes: 4

Views: 1917

Answers (2)

jsg
jsg

Reputation: 36

Just need to call the good node_module @strapi/strapi instead of strapi

  • Ubuntu 20.04.4 LTS
  • Plesk Obsidian
  • Strapi 4.1.9
  • npm 6.14.17
  • node 14.19.3
const strapi = require('@strapi/strapi');
strapi().start();

Upvotes: 2

Sjouke
Sjouke

Reputation: 329

Make sure you run npm install before trying to start the application.

I don't remember how to do this from the admin interface, but you can SSH into the server and run <path-to-npm>/npm install

Upvotes: 0

Related Questions