serverless-webpack
serverless-webpack copied to clipboard
"Packaging: No files found" in deploy.
I develop appsync by using serverless framework.
I could deploy api successfully.
Next I wanted to test it locally, so I introduced serverless-webpack, serverless-appsync-simulator, serverless-dynamodb-local and serverless-offline.
I could test in local but couldn't deploy with the following error.
I comment outed serverless-webpack in serverless.yml. I could deploy successfully again.
What should I do ?
error-log
$ serverless deploy -v --aws-profile private_name
Serverless: To ensure safe major version upgrades ensure "frameworkVersion" setting in service configuration (recommended setup: "frameworkVersion: ^2.48.0")
Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command upgrade
Serverless: Load command uninstall
Serverless: Load command delete-appsync
Serverless: Load command validate-schema
Serverless: Load command graphql-playground
Serverless: Load command deploy-appsync
Serverless: Load command update-appsync
Serverless: Load command webpack
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Load command output
Serverless: Load command output:get
Serverless: Load command output:list
Serverless: Load command param
Serverless: Load command param:get
Serverless: Load command param:list
Serverless: Load command studio
Serverless: Skipping variables resolution with old resolver (new resolver reported no more variables to resolve)
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
AppSync Plugin: GraphQl schema valid
Serverless: Invoke webpack:validate
Serverless: Using configuration:
{
"includeModules": true,
"webpackConfig": "webpack.config.js",
"packager": "npm",
"packagerOptions": {},
"keepOutputDirectory": false,
"concurrency": 8
}
Serverless: Removing /Users/name/Documents/git/Serverless/serverless-appsync-tutorial/.webpack
Serverless: Invoke webpack:compile
Serverless: Bundling with Webpack...
webpack compiled successfully in 38 ms
Serverless: Invoke webpack:package
Serverless: Fetch dependency graph from /Users/name/Documents/git/Serverless/serverless-appsync-tutorial/package.json
Serverless: Ignoring 1 NPM errors:
Serverless: => missing: serverless@^1.60.0 || 2, required by [email protected]
Serverless: No external modules needed
Serverless Error ----------------------------------------
ServerlessError: Packaging: No files found
at ServerlessWebpack.zip (/Users/name/Documents/git/Serverless/serverless-appsync-tutorial/node_modules/serverless-webpack/lib/packageModules.js:62:19)
at /Users/name/Documents/git/Serverless/serverless-appsync-tutorial/node_modules/serverless-webpack/lib/packageModules.js:139:10
at tryCatcher (/Users/name/Documents/git/Serverless/serverless-appsync-tutorial/node_modules/bluebird/js/release/util.js:16:23)
at Object.gotValue (/Users/name/Documents/git/Serverless/serverless-appsync-tutorial/node_modules/bluebird/js/release/reduce.js:166:18)
at Object.gotAccum (/Users/name/Documents/git/Serverless/serverless-appsync-tutorial/node_modules/bluebird/js/release/reduce.js:155:25)
at Object.tryCatcher (/Users/name/Documents/git/Serverless/serverless-appsync-tutorial/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/name/Documents/git/Serverless/serverless-appsync-tutorial/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/Users/name/Documents/git/Serverless/serverless-appsync-tutorial/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromiseCtx (/Users/name/Documents/git/Serverless/serverless-appsync-tutorial/node_modules/bluebird/js/release/promise.js:641:10)
at _drainQueueStep (/Users/name/Documents/git/Serverless/serverless-appsync-tutorial/node_modules/bluebird/js/release/async.js:97:12)
at _drainQueue (/Users/name/Documents/git/Serverless/serverless-appsync-tutorial/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/Users/name/Documents/git/Serverless/serverless-appsync-tutorial/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/Users/name/Documents/git/Serverless/serverless-appsync-tutorial/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (node:internal/timers:464:21)
serverless.yml
service: serverless-appsync-tutorial
provider:
name: aws
runtime: nodejs12.x
stage: dev
region: ap-northeast-2
plugins:
- serverless-appsync-plugin
- serverless-webpack
- serverless-dynamodb-local
- serverless-appsync-simulator
- serverless-offline
custom:
webpack:
includeModules: true
# some config
dynamodb:
stages:
- dev
start:
port: 8000
inMemory: true
migrate: true
seed: true
seed:
dev:
sources:
- table: UserTable
sources: [./migrations/user.json]
- table: ChatMessageTable
sources: [./migrations/chatMessage.json]
serverless-offline:
useChildProcesses: true
allowCache: true
appsync-simulator:
apiKey: da2-******
package.json
{
"dependencies": {
"serverless-appsync-plugin": "^1.11.3",
"serverless-appsync-simulator": "^0.17.0",
"serverless-dynamodb-local": "^0.2.39",
"serverless-offline": "^7.0.0",
"serverless-webpack": "^5.5.1",
"webpack": "^5.40.0",
"webpack-cli": "^4.7.2",
"webpack-node-externals": "^3.0.0"
}
}
webpack.config.js
const webpack = require("webpack");
const slsw = require("serverless-webpack");
const nodeExternals = require("webpack-node-externals");
module.exports = {
entry: slsw.lib.entries,
mode: slsw.lib.webpack.isLocal ? "development" : "production",
target: "node",
externals: [nodeExternals()],
// plugins: [new webpack.IgnorePlugin({resourceRegExp: /^pg-native$/})],
};
My environment
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 16.0.0
Framework Version: 2.48.0
Plugin Version: 5.4.1
SDK Version: 4.2.3
Components Version: 3.12.0
What version of serverless-webpack are you using?
Could you update line 62 of /Users/name/Documents/git/Serverless/serverless-appsync-tutorial/node_modules/serverless-webpack/lib/packageModules.js with:
-const error = new this.serverless.classes.Error('Packaging: No files found');
+const error = new this.serverless.classes.Error('Packaging: No files found: ' + directory);
Try again and show me the new error message?
@j0k3r I use version 5.5.1.
{
"dependencies": {
"serverless-appsync-plugin": "^1.11.3",
"serverless-appsync-simulator": "^0.17.0",
"serverless-dynamodb-local": "^0.2.39",
"serverless-offline": "^7.0.0",
"serverless-webpack": "^5.5.1",
"webpack": "^5.40.0",
"webpack-cli": "^4.7.2",
"webpack-node-externals": "^3.0.0"
}
}
@j0k3r I added directory output and get result.
No files found: /Users/name/Documents/git/Serverless/serverless-appsync-tutorial/.webpack/service
Checking your serverless.yml file, you don't have functions declared. Is it intended? I think that's why serverless-webpack doesn't find any files to package.
@j0k3r Yeah I don't want to deploy functions. Only AppSync and DynamoDB. How can I make this happen?
@j0k3r At the moment I am using serverless-webpack for local testing.
I've never done that. But at least, I don't think you need serverless-webpack.
@j0k3r @yukitaka13-1110
Problem:
Checking your
serverless.ymlfile, you don't have functions declared. Is it intended? I think that's why serverless-webpack doesn't find any files to package.
I just ran into this issue myself and can confirm this is correct.
I created a serverless project with sls create -t aws-nodejs-typescript because I wanted typings for my config file.
I only needed to create a S3 resource so no functions were needed and I removed them from my config. Upon running sls deploy, I got the error Packaging: No files found in packageModules.js and then ended up here lol.
Here is an example repo I made to reproduce the error.
Solution:
I took your advice and just commented out the plugins variable of the serverless.ts and then ran sls deploy and all was good! When functions are needed, just uncomment.
TODOs:
Ultimately, this issue was caused by the sls create template assuming that users who choose the aws-nodejs-typescript are 100% going to include a function in their serverless.ts config.
I'm not for sure where or what the fix should be if any to prevent others from going on the hour goose-hunt I did lol.
My recommended fix would be that the generated aws-nodejs-typescript has a comment regarding this in the config file.