Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Babel-loader - hidden dependency #66

Closed
mkozhukharenko opened this issue Oct 16, 2018 · 22 comments · Fixed by #137
Closed

[BUG] Babel-loader - hidden dependency #66

mkozhukharenko opened this issue Oct 16, 2018 · 22 comments · Fixed by #137
Labels

Comments

@mkozhukharenko
Copy link

mkozhukharenko commented Oct 16, 2018

after running command ./node_modules/.bin/netlify-lambda build functions-source/
I god

netlify-lambda: Building functions
Hash: 2f36233598c9262552e4
Version: webpack 4.20.2
Time: 1142ms
Built at: 2018-10-16 12:47:52
    Asset      Size  Chunks  Chunk Names
rating.js  1.21 KiB       0  rating
Entrypoint rating = rating.js
[0] ./rating.js 254 bytes {0} [built] [failed] [1 error]

ERROR in ./rating.js
Module build failed (from ../node_modules/babel-loader/lib/index.js):
TypeError: Cannot read property 'babel' of undefined
    at Object.module.exports (/Users/nikolay/Projects/autokwix/node_modules/babel-loader/lib/index.js:103:36)

after installing babel-loader - it started to work

how on earth?

@8eecf0d2
Copy link
Contributor

Which version of netlify-lambda are you using?

Versions prior to 1.x.x were using babel-loader@^7.1.2, now bumped to [email protected]

@mkozhukharenko
Copy link
Author

"1.0.2",

and after installing babel-loader to my project and running npm run develop I'm getting:

1:48:15 PM: 
1:48:15 PM:   Error: ./.cache/production-app.js
1:48:15 PM:   Module build failed: Error: Plugin/Preset files are not allowed to export obje  cts, only functions. In /opt/build/repo/node_modules/babel-preset-stage-0/lib/  index.js
1:48:15 PM:       at createDescriptor (/opt/build/repo/node_modules/@babel/core/lib/config/c  onfig-descriptors.js:178:11)
1:48:15 PM:       at items.map (/opt/build/repo/node_modules/@babel/core/lib/config/config-d  escriptors.js:109:50)
1:48:15 PM:       at Array.map (<anonymous>)
1:48:15 PM:       at createDescriptors (/opt/build/repo/node_modules/@babel/core/lib/config/  config-descriptors.js:109:29)
1:48:15 PM:       at createPresetDescriptors (/opt/build/repo/node_modules/@babel/core/lib/c  onfig/config-descriptors.js:101:10)
1:48:15 PM:       at passPerPreset (/opt/build/repo/node_modules/@babel/core/lib/config/conf  ig-descriptors.js:58:96)
1:48:15 PM:       at cachedFunction (/opt/build/repo/node_modules/@babel/core/lib/config/cac  hing.js:33:19)
1:48:15 PM:       at presets.presets (/opt/build/repo/node_modules/@babel/core/lib/config/co  nfig-descriptors.js:29:84)
1:48:15 PM:       at mergeChainOpts (/opt/build/repo/node_modules/@babel/core/lib/config/con  fig-chain.js:315:26)
1:48:15 PM:       at /opt/build/repo/node_modules/@babel/core/lib/config/config-chain.js:278  :7
1:48:15 PM:       at buildRootChain (/opt/build/repo/node_modules/@babel/core/lib/config/con  fig-chain.js:68:29)
1:48:15 PM:       at loadPrivatePartialConfig (/opt/build/repo/node_modules/@babel/core/lib/  config/partial.js:85:55)
1:48:15 PM:       at Object.loadPartialConfig (/opt/build/repo/node_modules/@babel/core/lib/  config/partial.js:110:18)
1:48:15 PM:       at Object.<anonymous> (/opt/build/repo/node_modules/babel-loader/lib/index  .js:140:26)
1:48:15 PM:       at Generator.next (<anonymous>)
1:48:15 PM:       at asyncGeneratorStep (/opt/build/repo/node_modules/babel-loader/lib/index  .js:3:103)
1:48:15 PM: 
1:48:15 PM: 
1:48:15 PM:   Error: ./src/cms/cms.js
1:48:15 PM:   Module build failed: Error: Plugin/Preset files are not allowed to export obje  cts, only functions. In /opt/build/repo/node_modules/babel-preset-stage-0/lib/  index.js
1:48:15 PM:       at createDescriptor (/opt/build/repo/node_modules/@babel/core/lib/config/c  onfig-descriptors.js:178:11)
1:48:15 PM:       at items.map (/opt/build/repo/node_modules/@babel/core/lib/config/config-d  escriptors.js:109:50)
1:48:15 PM:       at Array.map (<anonymous>)
1:48:15 PM:       at createDescriptors (/opt/build/repo/node_modules/@babel/core/lib/config/  config-descriptors.js:109:29)
1:48:15 PM:       at createPresetDescriptors (/opt/build/repo/node_modules/@babel/core/lib/c  onfig/config-descriptors.js:101:10)
1:48:15 PM:       at passPerPreset (/opt/build/repo/node_modules/@babel/core/lib/config/conf  ig-descriptors.js:58:96)
1:48:15 PM:       at cachedFunction (/opt/build/repo/node_modules/@babel/core/lib/config/cac  hing.js:33:19)
1:48:15 PM:       at presets.presets (/opt/build/repo/node_modules/@babel/core/lib/config/co  nfig-descriptors.js:29:84)
1:48:16 PM:       at mergeChainOpts (/opt/build/repo/node_modules/@babel/core/lib/config/con  fig-chain.js:315:26)
1:48:16 PM:       at /opt/build/repo/node_modules/@babel/core/lib/config/config-chain.js:278  :7
1:48:16 PM:       at buildRootChain (/opt/build/repo/node_modules/@babel/core/lib/config/con  fig-chain.js:68:29)
1:48:16 PM:       at loadPrivatePartialConfig (/opt/build/repo/node_modules/@babel/core/lib/  config/partial.js:85:55)
1:48:16 PM:       at Object.loadPartialConfig (/opt/build/repo/node_modules/@babel/core/lib/  config/partial.js:110:18)
1:48:16 PM:       at Object.<anonymous> (/opt/build/repo/node_modules/babel-loader/lib/index  .js:140:26)
1:48:16 PM:       at Generator.next (<anonymous>)
1:48:16 PM:       at asyncGeneratorStep (/opt/build/repo/node_modules/babel-loader/lib/index  .js:3:103)
1:48:16 PM:    @ multi cms
1:48:16 PM: 

if I remove babel-loader - everething if fine

@swyxio
Copy link
Contributor

swyxio commented Oct 17, 2018

hi Nikolay - can you remove node_modules and try again? we have babel loader in our dependencies... https://github.com/netlify/netlify-lambda/blob/master/package.json#L28

@swyxio swyxio added the triage label Oct 17, 2018
@CarlosMed
Copy link

I have been getting this same issue on a new create-react-app and was wondering why it wasn't working until finally doing a yarn add -D babel-loader and starting the netlify-lambda serve command all over again to which it works.

My conclusion is that it might have to do with react-scripts: 2.x.x.

My error was more along the lines of:
ERROR in Entry module not found: Error: Can't resolve 'babel-loader' in '/Users/[redacted]/Desktop/test/src/functions'

@swyxio
Copy link
Contributor

swyxio commented Nov 9, 2018

Thanks Carlos. I'm not too familiar with how babel-loader works to be honest - how can we "build it in" and make babel invisible for netlify-lambda users? i think that is what we want

@CarlosMed
Copy link

@sw-yx Seems as if it's a mixed bag.

Ex. I'll get the ERROR in Entry module not found: Error: Can't resolve 'babel-loader' in '/Users/[redacted]/Desktop/test/src/functions' from a clean install but when I install the babel loader I get:

yarn run v1.13.0-20181004.1524
$ netlify-lambda serve src/lambda
netlify-lambda: Starting server
Lambda server is listening on 9000
Unhandled rejection Error: Cannot find module '/Users/[redacted]/Desktop/test/lambda/hello'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.resolve (internal/modules/cjs/helpers.js:30:19)
    at Object.clearCache (/Users/[redacted]/Desktop/test/node_modules/netlify-lambda/lib/serve.js:111:36)
    at /Users/[redacted]/Desktop/test/node_modules/netlify-lambda/bin/cmd.js:38:16
    at Array.forEach (<anonymous>)
    at Watching.handler (/Users/[redacted]/Desktop/test/node_modules/netlify-lambda/bin/cmd.js:37:32)
    at compiler.hooks.done.callAsync (/Users/[redacted]/Desktop/test/node_modules/netlify-lambda/node_modules/webpack/lib/Watching.js:98:9)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/[redacted]/Desktop/test/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/Users/[redacted]/Desktop/test/node_modules/tapable/lib/Hook.js:154:20)
    at Watching._done (/Users/[redacted]/Desktop/test/node_modules/netlify-lambda/node_modules/webpack/lib/Watching.js:97:28)
    at onCompiled (/Users/[redacted]/Desktop/test/node_modules/netlify-lambda/node_modules/webpack/lib/Watching.js:47:18)
    at hooks.afterCompile.callAsync.err (/Users/[redacted]/Desktop/test/node_modules/netlify-lambda/node_modules/webpack/lib/Compiler.js:552:14)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/[redacted]/Desktop/test/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/Users/[redacted]/Desktop/test/node_modules/tapable/lib/Hook.js:154:20)
    at compilation.seal.err (/Users/[redacted]/Desktop/test/node_modules/netlify-lambda/node_modules/webpack/lib/Compiler.js:549:30)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/[redacted]/Desktop/test/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)

which leads me to believe it has to do with version mismatch as from what I've gathered netlify-lambda brings its own version of babel-loader.

If I delete the yarn.lock file and node_module then redo a yarn to reinstall everything and run the netlify-lambda serve src/lambda it begins to work.

Im not as familiar with babel but I'll see what can be done to get it from messing up like so.

Another thing I've noticed is using Yarn Plug and Play it gives the same error with no babel-loader and no matter what I do it will not work at all even if I try installing it.

@swyxio
Copy link
Contributor

swyxio commented Nov 10, 2018

ok and what babel and babel-loader version are you working with? we use babel 7 and babel-loader 8.

@stale
Copy link

stale bot commented Jan 9, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 9, 2019
@stale stale bot closed this as completed Jan 16, 2019
@wKovacs64
Copy link

Darn it, stalebot. This should be reopened.

@vojoup
Copy link

vojoup commented Feb 6, 2019

+1 on this

@swyxio swyxio reopened this Feb 6, 2019
@stale stale bot closed this as completed Feb 13, 2019
@josephmaxim
Copy link

Please reopen still not resolved.

@CarlosMed
Copy link

I can test this out later on but am unsure on how to troubleshoot aside from what I posted above.

@Jones-S
Copy link

Jones-S commented Feb 16, 2019

Had the same problem. Only following @CarlosMed instructions helped...

@swyxio swyxio reopened this Feb 16, 2019
@stale stale bot removed the stale label Feb 16, 2019
@swyxio
Copy link
Contributor

swyxio commented Feb 16, 2019

alright i'll reopen this and will welcome PRs for it, thanks for feedback! not working on this myself yet due to other priorities

@swyxio swyxio pinned this issue Feb 16, 2019
@codepunkt
Copy link
Contributor

codepunkt commented Feb 27, 2019

I have a (hopefully) reproducible example here:
https://github.com/paderbornjs/site/

Steps to reproduce:

  • Clone the repository
  • Run "yarn" in root to install dependencies
  • Switch into directory packages/api
  • Run "yarn run start:lambda" to start netlify-lambda

Can someone please have a look?

@sebbean
Copy link

sebbean commented Mar 14, 2019

definitely having same issue, project is fullmoon.netlify.com

@sebbean
Copy link

sebbean commented Mar 14, 2019

this seemed to help
symfony/webpack-encore#237

@swyxio
Copy link
Contributor

swyxio commented Mar 15, 2019

good stuff. will still welcome PRs without actively looking at it right now.

@codepunkt
Copy link
Contributor

@sw-yx Will you be actively looking at it some time soon?

Removing node_modules, yarn.lock or a combination of those didn't help.

@josephmaxim
Copy link

@codepunkt just run "yarn add babel-loader" for a quick fix.

@bogdansoare
Copy link

also having this issue

@cliffasaurus
Copy link

cliffasaurus commented Apr 28, 2019

Update: I figured it out. To anyone out there using react-static (older versions ~before v6.x.x) with netlify-lambda (v0.4.0), I needed to upgrade both my versions of react-static(now v7.x.x) and netlify lambda(now v1.4.5).


Hi @sw-yx I had lambda ^0.4.0 and it started to fail all of a sudden, without touching any config nor the functions and experienced this during build:

11:59:35 PM: failed during stage 'preparing functions for deployment': exit status 1
11:59:34 PM: Error: Cannot find module './dist/react-hot-loader.production.min.js' from '/opt/build/repo/dist/lambda'
11:59:34 PM: Failing build: Failed to prepare functions for deployment

I upgraded to netlify-lambda: ^1.4.5 and yarn added -D babel-loader: ^8.0.5 but the build functions failed and it seems to have something to do with babel-loader :(

2:55:11 PM: netlify-lambda: Building functions
2:55:12 PM: Hash: 101544bdec7f89cd2c64
2:55:12 PM: Version: webpack 4.30.0
2:55:12 PM: Time: 456ms
2:55:12 PM: Built at: 2019-04-28 06:55:12
2:55:12 PM:        Asset      Size  Chunks  Chunk Names
2:55:12 PM: recaptcha.js  3.04 KiB       0  recaptcha
2:55:12 PM: Entrypoint recaptcha = recaptcha.js
2:55:12 PM: [0] ./recaptcha.js 2.08 KiB {0} [built] [failed] [1 error]
2:55:12 PM: ERROR in ./recaptcha.js
2:55:12 PM: Module build failed (from ../node_modules/babel-loader/lib/index.js):
2:55:12 PM: Error: Plugin/Preset files are not allowed to export objects, only functions. In /opt/build/repo/node_modules/react-static/babel-preset.js

@erezrokah erezrokah unpinned this issue Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.