elmasse / nextein

A static site generator with markdown + react for Next.js
https://nextein.elmasse.io
ISC License
898 stars 34 forks source link

no such file or directory, open '.next/nextein_ipc.cache' #346

Closed cykoder closed 2 years ago

cykoder commented 2 years ago

Hello!

I am encountering this bug using nextein 4 (any version) on Linux. I was able to solve it by modifying nextein to not use the .next folder for its own cache. It seems this folder gets deleted/reset during build step, as even if I make the file automatically it will compile then delete itself.

Could reproduce in the nextein-starter repo, based my project from that. Also happens on vercel. Build log:

2022-02-12T04:04:11.767Z  
2022-02-12T04:04:11.774Z  Retrieving list of deployment files...
2022-02-12T04:04:13.339Z  Downloading 76 deployment files...
2022-02-12T04:04:15.412Z  Analyzing source code...
2022-02-12T04:04:15.521Z  Warning: Due to `builds` existing in your configuration file, the Build and Development Settings defined in your Project Settings will not apply. Learn More: https://vercel.link/unused-build-settings
2022-02-12T04:04:15.788Z  Installing build runtime...
2022-02-12T04:04:18.455Z  Build runtime installed: 2.667s
2022-02-12T04:04:19.211Z  Looking up build cache...
2022-02-12T04:04:19.728Z  Build Cache not found
2022-02-12T04:04:19.857Z  Installing dependencies...
2022-02-12T04:04:20.107Z  yarn install v1.22.17
2022-02-12T04:04:20.178Z  [1/4] Resolving packages...
2022-02-12T04:04:20.400Z  [2/4] Fetching packages...
2022-02-12T04:04:34.069Z  [3/4] Linking dependencies...
2022-02-12T04:04:34.071Z  warning "next > styled-jsx > @babel/plugin-syntax-jsx@7.14.5" has unmet peer dependency "@babel/core@^7.0.0-0".
2022-02-12T04:04:34.073Z  warning " > eslint-config-airbnb-base@15.0.0" has unmet peer dependency "eslint-plugin-import@^2.25.2".
2022-02-12T04:04:34.074Z  warning "eslint-config-next > @typescript-eslint/parser > @typescript-eslint/typescript-estree > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
2022-02-12T04:04:40.117Z  [4/4] Building fresh packages...
2022-02-12T04:04:40.389Z  Done in 20.29s.
2022-02-12T04:04:40.613Z  Running "yarn run build"
2022-02-12T04:04:40.796Z  yarn run v1.22.17
2022-02-12T04:04:40.832Z  $ npm run export
2022-02-12T04:04:41.053Z  npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1644638680835-0.1228426460323897/node but npm is using /node14/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
2022-02-12T04:04:41.054Z  
2022-02-12T04:04:41.054Z  > platformer-blog@1.0.0 export /vercel/path1
2022-02-12T04:04:41.054Z  > next build && next export
2022-02-12T04:04:41.054Z  
2022-02-12T04:04:41.854Z  Attention: Next.js now collects completely anonymous telemetry regarding usage.
2022-02-12T04:04:41.854Z  This information is used to shape Next.js' roadmap and prioritize features.
2022-02-12T04:04:41.855Z  You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
2022-02-12T04:04:41.855Z  https://nextjs.org/telemetry
2022-02-12T04:04:41.855Z  
2022-02-12T04:04:41.916Z  info  - Checking validity of types...
2022-02-12T04:04:44.091Z  
2022-02-12T04:04:44.091Z  ./pages/media.js
2022-02-12T04:04:44.091Z  87:23  Warning: Do not use <img>. Use Image from 'next/image' instead. See https://nextjs.org/docs/messages/no-img-element.  @next/next/no-img-element
2022-02-12T04:04:44.091Z  
2022-02-12T04:04:44.092Z  info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
2022-02-12T04:04:44.106Z  info  - Creating an optimized production build...
2022-02-12T04:04:55.969Z  info  - Compiled successfully
2022-02-12T04:04:55.969Z  info  - Collecting page data...
2022-02-12T04:04:56.299Z  
2022-02-12T04:04:56.299Z  > Build error occurred
2022-02-12T04:04:56.301Z  [Error: ENOENT: no such file or directory, open '/vercel/path1/.next/nextein_ipc.cache'] {
2022-02-12T04:04:56.301Z    type: 'Error',
2022-02-12T04:04:56.301Z    errno: -2,
2022-02-12T04:04:56.301Z    code: 'ENOENT',
2022-02-12T04:04:56.301Z    syscall: 'open',
2022-02-12T04:04:56.301Z    path: '/vercel/path1/.next/nextein_ipc.cache'
2022-02-12T04:04:56.301Z  }
2022-02-12T04:04:56.336Z  npm ERR! code ELIFECYCLE
2022-02-12T04:04:56.336Z  npm ERR! errno 1
2022-02-12T04:04:56.339Z  npm ERR! platformer-blog@1.0.0 export: `next build && next export`
2022-02-12T04:04:56.339Z  npm ERR! Exit status 1
2022-02-12T04:04:56.339Z  npm ERR! 
2022-02-12T04:04:56.339Z  npm ERR! Failed at the platformer-blog@1.0.0 export script.
2022-02-12T04:04:56.339Z  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2022-02-12T04:04:56.347Z  
2022-02-12T04:04:56.348Z  npm ERR! A complete log of this run can be found in:
2022-02-12T04:04:56.348Z  npm ERR!     /vercel/.npm/_logs/2022-02-12T04_04_56_340Z-debug.log
2022-02-12T04:04:56.360Z  error Command failed with exit code 1.
2022-02-12T04:04:56.361Z  info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2022-02-12T04:04:56.369Z  Error: Command "yarn run build" exited with 1
2022-02-12T04:04:57.186Z  
elmasse commented 2 years ago

hi @SamHellawell

Thanks for reporting this issue. Could you please confirm if this happens with a fresh install (remove node_modules and .next folder, then npm install) and using nextein v4.0.3?

That issue should be fixed in that version, I will also update nextein-starter. I just checked it and I missed the version upgrade.

Also, if this is still happening can you confirm the next version you are using?

Thanks again!

cykoder commented 2 years ago

Hey,

Yeah same thing happens in a fresh install (first time I installed nextein I got this error). It also happens under v4.0.2 and v4.0.1

Interestingly, if i disable linting in the next build step then all works as expected - even on vercel.

Using:

    "next": "12.0.5",
    "nextein": "4.0.1",

I had another issue causing me to downgrade to 4.0.1 btw, but it may have been related to this/missing cache (entries is undefined, when should be array).

elmasse commented 2 years ago

I just tried enabling the linter on nextein-starter and I can reproduce an error with next v12.0.10 and nextein v4.0.3:

> Build error occurred
TypeError: Cannot read property 'map' of undefined
    at metadata (/Users/elmasse/Projects/elmasse/nextein-starter/node_modules/nextein/dist/entries/metadata.js:15:18)
    at async dataFilterBy (/Users/elmasse/Projects/elmasse/nextein-starter/node_modules/nextein/dist/entries/fetcher.js:34:18)
    at async getStaticPaths (/Users/elmasse/Projects/elmasse/nextein-starter/.next/server/pages/[name].js:34:18)
    at async buildStaticPaths (/Users/elmasse/Projects/elmasse/nextein-starter/node_modules/next/dist/build/utils.js:497:31)
    at async /Users/elmasse/Projects/elmasse/nextein-starter/node_modules/next/dist/build/utils.js:640:119
    at async Span.traceAsyncFn (/Users/elmasse/Projects/elmasse/nextein-starter/node_modules/next/dist/trace/trace.js:75:20) {
  type: 'TypeError'
}
info  - Collecting page data .%                                                                                                                                                                    

I'll give it a look on why the linter causes this error. It seems to be a TypeError, which might be related to what you mentioned about entries being undefined while the Type system expects an Array.

cykoder commented 2 years ago

Yep that's the exact error I was getting with latest nextein (didnt have yet to reproduce fully, but thats 100% it). I am not sure if disabling the linter resolves the "map of undefined" error - but it does resolve the cache file missing issue. I think ultimately, you should just not use the .next folder as it seems to break a few times over this projects life due to nextjs changes. Might make your life a bit easier.

These may be two separate errors, was just a hunch could be cache file related.

Btw, great project - just what I needed once I got it working. Also worked out of the box with https://www.npmjs.com/package/next-sitemap - might be worth adding that to the starter as its a must for indexing blogs

elmasse commented 2 years ago

Yes, agreed on both statements. I wanted to avoid adding more entries to gitignore but this is a trivial thing when compared to having to understand why this is not working on certain stages.

The second issue is weird, but yet I want to understand why enabling a linter will blow the entire stack.

That project (next-sitemap) looks great. I will add it to nextein site and eventually to a blog-starter, I want to keep nextein-starter as minimal as possible since I use it to test scenarios like this issue.

elmasse commented 2 years ago

@SamHellawell I published a patched version v4.0.4 please give it a try and feel free to comment or close the issue if it goes well.

Thanks again for using nextein and for taking the time and effort to report the issue!

cykoder commented 2 years ago

All working locally and on vercel, thanks for the quick fix! Hope nextein gets more users, great bit of kit.