error with scandir node_modules during packaging
See original GitHub issueHere’s an example repo:
https://github.com/jmparsons/webpack-test
I’m using serverless 0.19. The latest webpack and serverless webpack.
I’m getting Error: ENOENT: no such file or directory, scandir 'node_modules'
After running serverless deploy
in the src/tester
folder.
cd src/tester
serverless deploy
Full output:
{ Error: ENOENT: no such file or directory, scandir 'node_modules'
at Object.fs.readdirSync (fs.js:910:18)
at readDir (/Users/_/Desktop/webpack-test/node_modules/webpack-node-externals/index.js:12:19)
at nodeExternals (/Users/_/Desktop/webpack-test/node_modules/webpack-node-externals/index.js:95:65)
at Object.<anonymous> (/Users/_/Desktop/webpack-test/webpack.config.js:8:15)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at ServerlessWebpack.validate (/Users/_/Desktop/webpack-test/node_modules/serverless-webpack/lib/validate.js:94:28)
at ServerlessWebpack.tryCatcher (/Users/_/Desktop/webpack-test/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/_/Desktop/webpack-test/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/_/Desktop/webpack-test/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromiseCtx (/Users/_/Desktop/webpack-test/node_modules/bluebird/js/release/promise.js:606:10)
at Async._drainQueue (/Users/_/Desktop/webpack-test/node_modules/bluebird/js/release/async.js:138:12)
at Async._drainQueues (/Users/_/Desktop/webpack-test/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/Users/_/Desktop/webpack-test/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:781:20)
at tryOnImmediate (timers.js:743:5)
at processImmediate [as _immediateCallback] (timers.js:714:5)
errno: -2,
code: 'ENOENT',
syscall: 'scandir',
path: 'node_modules' }
Serverless: Bundling with Webpack...
Time: 428ms
Asset Size Chunks Chunk Names
index.js 4.76 kB 0 [emitted] index
[0] ./index.js 524 bytes {0} [built]
[1] ./Tester.js 731 bytes {0} [built]
[2] /Users/_/Desktop/webpack-test/node_modules/babel-runtime/core-js/json/stringify.js 95 bytes {0} [built]
[3] /Users/_/Desktop/webpack-test/node_modules/core-js/library/fn/json/stringify.js 242 bytes {0} [built]
[4] /Users/_/Desktop/webpack-test/node_modules/core-js/library/modules/_core.js 117 bytes {0} [built]
[5] /Users/_/Desktop/webpack-test/node_modules/babel-runtime/helpers/classCallCheck.js 208 bytes {0} [built]
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
.....
Serverless: Stack create finished...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service .zip file to S3 (1.6 KB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
....................................
Serverless: Stack update finished...
Service Information
service: webpack-test-
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Error: ENOENT: no such file or directory, scandir
I got the error 'Error: ENOENT: no such file or directory, scandir '**/node_modules/node-sass/vendor', this solution helped me resolve it.
Read more >Fix "no such file or directory, scandir" - David Walsh Blog
Old Man Walsh™ just wants yarn install to work so he can get on with his work day. The npm rebuild {package} call...
Read more >How to fix: npm ERR! enoent ENOENT: no such file or ...
I recently struggled for a while with an npm error thrown when executing npm install of some package. The error message was npm...
Read more >Resolving EACCES permissions errors when installing ...
Resolving EACCES permissions errors when installing packages globally · Reinstall npm with a node version manager (recommended),. or · Manually change npm's ......
Read more >Getting the following Error (ENOENT: no such file or directory ...
... ENOENT: no such file or directory, scandir 'packages/rocketchat-katex/node_modules/katex/dist/fonts/' at Error (native) at Object.fs.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok I see.
I just saw that node externals has a modulesDir option (see https://www.npmjs.com/package/webpack-node-externals). Instead of moving the serverless.yml, you could try to use
nodeExternals({ modulesDir: '../../node_modules' })
. Serverless (and the plugin) always uses its service dir (/src/tester in your case) as base reference, so it might be sufficient to tell nodeExternals where to find the modules in your webpack.conf.js.You’re welcome 😉