sls offline cloudside command gives error webpack plugin could not find the configuration file ... webpack.config.js

Viewed 613

I'm working on a project that uses AWS Lambda and serverless (sls) technology. When trying to run npm start which runs sls offline cloudside I get the error:

  The webpack plugin could not find the configuration file at: c:\Play\MyProj\src\myproj-backend\services\user-service\d:\Play\MyProj\src\myproj-backend\services\user-service\node_modules\serverless-bundle\src\webpack.config.js

The full output is:

npm start
> users-service@1.0.0 start c:\Play\MyProj\src\myproj-backend\services\user-service
> sls offline cloudside

Serverless: Deprecation warning: Starting with version 3.0.0, following property will be replaced:
              "provider.iamRoleStatements" -> "provider.iam.role.statements"
            More Info: https://www.serverless.com/framework/docs/deprecations/#PROVIDER_IAM_SETTINGS
Serverless: Deprecation warning: Resolution of lambda version hashes was improved with better algorithm, which will be used in next major release.
            Switch to it now by setting "provider.lambdaHashingVersion" to "20201221"
            More Info: https://www.serverless.com/framework/docs/deprecations/#LAMBDA_HASHING_VERSION_V2
Serverless: Loading cloudside resources for 'users-service-dev' stack.

 Serverless Error ----------------------------------------

  The webpack plugin could not find the configuration file at: c:\Play\MyProj\src\myproj-backend\services\user-service\d:\Play\MyProj\src\myproj-backend\services\user-service\node_modules\serverless-bundle\src\webpack.config.js

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          win32
     Node Version:              12.16.2
     Framework Version:         2.30.2
     Plugin Version:            4.5.1
     SDK Version:               4.2.0
     Components Version:        3.7.3

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! users-service@1.0.0 start: `sls offline cloudside`
npm ERR! Exit status 1

But what is strange is that the same git project works on another development box I use. Any idea's why this isn't working?

1 Answers

The reason for this is so bizarre and likely to be related to the way nodejs resolves files on windows when SYMLINKD directories are involved. No one else is likely to have this error but they might so I'm posting my answer.

My host has two disks: c: and d:. For consistency with my other machines, I do all my work on c:\play so that it's simpler for me. On the host that had the problem I had created a SYMLINKD from c:\play to d:\play. Below is the output of the dir command to show what I'm saying:

c:\>dir
04/12/2020  07:59 PM    <SYMLINKD>     Play [d:\Play]

So when I go into the c:\Play directory it is really going into the d:\Play directory, so the following two commands put me into the exact same directory:

cd /d c:\play\myproj\myproj-backend-services\user-service
cd /d d:\play\myproj\myproj-backend-services\user-service

When I ran sls offline cloudside the webpack.config.js file could not be found. The build was looking for the file:

c:\Play\MyProj\src\myproj-backend\services\user-service\d:\Play\MyProj\src\myproj-backend\services\user-service\node_modules\serverless-bundle\src\webpack.config.js

Upon closer inspection, I realized that the filename was corrupt and something was sticking two directories together. Namely these two strings were being stuck together to make the webpack.config.js file.

c:\Play\MyProj\src\myproj-backend\services\user-service\
d:\Play\MyProj\src\myproj-backend\services\user-service\node_modules\serverless-bundle\src\webpack.config.js

The webpack.config.js file did exist, and when I changed to the D: drive everything worked as expected. The error output line that alerted me was:

The webpack plugin could not find the configuration file at: c:\Play\MyProj\src\myproj-backend\services\user-service\d:\Play\MyProj\src\myproj-backend\services\user-service\node_modules\serverless-bundle\src\webpack.config.js

So if anyone else in Windows has used SYMLINKD (See mklink /d), then you too might run into this problem.

When working correctly (running from the D: drive) the output was:

d:\Play\MyProj\src\myproj-backend\services\user-service>npm start

> users-service@1.0.0 start d:\Play\MyProj\src\myproj-backend\services\user-service
> sls offline cloudside

Serverless: Deprecation warning: Starting with version 3.0.0, following property will be replaced:
              "provider.iamRoleStatements" -> "provider.iam.role.statements"
            More Info: https://www.serverless.com/framework/docs/deprecations/#PROVIDER_IAM_SETTINGS
Serverless: Deprecation warning: Resolution of lambda version hashes was improved with better algorithm, which will be used in next major release.
            Switch to it now by setting "provider.lambdaHashingVersion" to "20201221"
            More Info: https://www.serverless.com/framework/docs/deprecations/#LAMBDA_HASHING_VERSION_V2
Serverless: Loading cloudside resources for 'users-service-dev' stack.
Serverless: Bundling with Webpack...
Serverless: Watching for changes...
offline: Starting Offline: dev/us-east-1.
offline: Offline [http for lambda] listening on http://localhost:3002
offline: Function names exposed for local invocation by aws-sdk:
           * createUser: users-service-dev-createUser
           * getUser: users-service-dev-getUser
           * signup: users-service-dev-signup
           * login: users-service-dev-login

   ┌──────────────────────────────────────────────────────────────────────────────┐
   │                                                                              │
   │   POST | http://localhost:4321/dev/user/create                               │
   │   POST | http://localhost:4321/2015-03-31/functions/createUser/invocations   │
   │   GET  | http://localhost:4321/dev/user                                      │
   │   POST | http://localhost:4321/2015-03-31/functions/getUser/invocations      │
   │   POST | http://localhost:4321/dev/user/signup                               │
   │   POST | http://localhost:4321/2015-03-31/functions/signup/invocations       │
   │   POST | http://localhost:4321/dev/user/login                                │
   │   POST | http://localhost:4321/2015-03-31/functions/login/invocations        │
   │                                                                              │
   └──────────────────────────────────────────────────────────────────────────────┘

offline: [HTTP] server ready: http://localhost:4321 �
offline:
offline: Enter "rp" to replay the last request
Related