with-react-helmet, using-router, basic-css etc
Fails to build with bable error:
{ Error: Cannot find module './dist/server/build/babel/preset'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:571:15)
at Function.Module._load (internal/modules/cjs/loader.js:497:25)
at Module.require (internal/modules/cjs/loader.js:626:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/Users/a_user/dev/nextbug/next.js/babel.js:1:80)
at Module._compile (internal/modules/cjs/loader.js:678:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
at Function.Module._load (internal/modules/cjs/loader.js:520:3)
at Module.require (internal/modules/cjs/loader.js:626:17)
at require (internal/modules/cjs/helpers.js:20:18)
at requireModule (/Users/a_user/dev/nextbug/next.js/examples/with-react-helmet/node_modules/@babel/core/lib/config/files/plugins.js:142:12)
at loadPreset (/Users/a_user/dev/nextbug/next.js/examples/with-react-helmet/node_modules/@babel/core/lib/config/files/plugins.js:56:15)
at createDescriptor (/Users/a_user/dev/nextbug/next.js/examples/with-react-helmet/node_modules/@babel/core/lib/config/config-descriptors.js:152:21)
at /Users/a_user/dev/nextbug/next.js/examples/with-react-helmet/node_modules/@babel/core/lib/config/config-descriptors.js:104:12 code: 'MODULE_NOT_FOUND' }
Steps to reproduce the behavior, please provide code snippets or a repository:
git clone [email protected]:zeit/next.js.git && cd ./next.js/examples/basic-css && yarn install && yarn run build
Should build without error
osx6.0.3I think it's something to do with babel dependencies
Probably related to #4467
If you git clone you have to build Next.js (yarn build in the main directory) first before executing any of the examples, since the built babel preset is used. This is why none of the instructions for the examples mention cloning the repository 馃憤 Also cloning the repository for 1 out of 100+ examples takes a lot of time usually, that's why we favor downloading / npx init / yarn create
There's no indication in the package.json that this is the case - how does that actually work? (Genuinely don't understand how that is happening)
Babel looks recursively up the tree for a .babelrc, there is no way to disable this, so we had to add a .babelrc in the examples directory, except that doesn't allow for finding the respective next/babel for the example. So you have to manually build next.js and then the next/babel preset is available.
This is the babelrc: https://github.com/zeit/next.js/blob/canary/examples/.babelrc
Ahh, thanks!
So does it mean that in our own app, we need to include this .babelrc file too?
Most helpful comment
If you
git cloneyou have to build Next.js (yarn buildin the main directory) first before executing any of the examples, since the built babel preset is used. This is why none of the instructions for the examples mention cloning the repository 馃憤 Also cloning the repository for 1 out of 100+ examples takes a lot of time usually, that's why we favor downloading /npx init/yarn create