Currently
I cannot get my existing client + server to run, alongside serverless-offline.
DIRECTORY:
root:
- package.json
- /my-project
-- /serverless
--- ...
-- handler.js
-- serverless.yml
PACKAGE.JSON <-- uses concurrently to run multiple services simultaneously
"scripts": {
"start": "concurrently \"npm start --prefix client\" \"node index.js\" \"serverless offline start\""
}
Problem
When running npm start at root directory, the following error is returned:
Serverless command "offline" not found. Did you mean "config"? Run "serverless help" for a list of all available commands.
Note: when I run serverless offline start
in \my-project
, the command executes successfully and serverless-offline runs.
Question
serverless offline start
command in the context of /my-project
orNotes
I have tried answer run npm script from different repository but failed to get it working. Perhaps because I am trying to run a command (i.e. serverless) not a script file from a different directory context.
The issue had nothing to do with serverless, but rather my novice experience with setting up scripts within package.json. There were 2 options to run serverless offline start
from the parent project folder.
Option 1
Inserting cd my-project &&
before invoking serverless offline start
"scripts": {
"start": "concurrently \"npm start --prefix client\" \"node index.js\" \"cd my-project && serverless offline start\""
}
Option 2
Adding --prefix my-project
to serverless offline start
command. Note: I have not tested option 2
"scripts": {
"start": "concurrently \"npm start --prefix client\" \"node index.js\" \"serverless offline start --prefix my-project\""
}