serverless / serverless-plugin-typescript

Serverless plugin for zero-config Typescript support
MIT License
783 stars 223 forks source link

Bad/misleasing error message if project has no functions #206

Open ThomasEg opened 4 years ago

ThomasEg commented 4 years ago

Just spent half a day tracking this issue down, so i thought that maybe someone else might find this usefull on Google.... and it is something that should be fixed IMO...

I started on a new and small project, where we needed a bit of infrastructure(S3 bucket) and a single function. I thought "i'll start with the bucket and then add the function in step two".... but...that sent me down a rabbit hole tracking down a strange error...

First, here is the error i got when i tried to deploy my new service:

  Error: ENOENT: no such file or directory, stat 'C:\Users\Thomas\Documents\GitHub\Foo\Bar\.build\.serverless'
      at PluginManager.invoke (C:\Users\Thomas\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:490:22)
      at PluginManager.spawn (C:\Users\Thomas\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:510:17)
      at Deploy.BbPromise.bind.then (C:\Users\Thomas\AppData\Roaming\npm\node_modules\serverless\lib\plugins\deploy\deploy.js:115:50)

...followed by this on the next attempts at the deployment:

  Error: EPERM: operation not permitted, unlink 'C:\Users\Thomas\Documents\GitHub\Foo\Bar\.build\node_modules'
      at Object.unlinkSync (fs.js:956:3)
      at TypeScriptPlugin.<anonymous> (C:\Users\Thomas\Documents\GitHub\Foo\Bar\node_modules\serverless-plugin-typescript\src\index.ts:195:12)
      at Generator.next (<anonymous>)
      at C:\Users\Thomas\Documents\GitHub\Foo\Bar\node_modules\serverless-plugin-typescript\dist\src\index.js:7:71
      at new Promise (<anonymous>)
      at __awaiter (C:\Users\Thomas\Documents\GitHub\Foo\Bar\node_modules\serverless-plugin-typescript\dist\src\index.js:3:12)        
      at TypeScriptPlugin.copyDependencies (C:\Users\Thomas\Documents\GitHub\Foo\Bar\node_modules\serverless-plugin-typescript\dist\src\index.js:166:16)
      at TypeScriptPlugin.<anonymous> (C:\Users\Thomas\Documents\GitHub\Foo\Bar\node_modules\serverless-plugin-typescript\src\index.ts:45:20)
      at Generator.next (<anonymous>)
      at fulfilled (C:\Users\Thomas\Documents\GitHub\Foo\Bar\node_modules\serverless-plugin-typescript\dist\src\index.js:4:58)        
      at process._tickCallback (internal/process/next_tick.js:68:7)

...so.... i tried all solutions i could find: clearing node_modules and deleting all ".whatever" directories... i also tried cleaning up my global NPM packages to no avail...

The only way i could get it to deploy was by removing the "serverless-plugin-typescript"-plugin from the "plugins"-section of serverless.yml...

However, if you add a function to the project, everything works!

So this bugreport is to do two things: