Comments (16)
这是个有趣的提议!
- 据我所知,腾讯云是支持Serverless应用部署的,同时也有对NextJS的😂
- 但遗憾的是腾讯云似乎对Next的兼容性并不太好,我的部署尝试并不成功。看来NextJS还是和Vercel比较默契。
from notionnext.
我也试了一下,并且查看了下issue貌似是因为包过大引起的,能否缩减一下包的体积呢?已经超过200m了。
from notionnext.
✅包过大可能影响编译
日志中确实有提到包的体积过大的可能性:
[2022-03-28 16:51:05] 当前项目文件大小超过200MB,部署有可能会失败。如果失败建议使用 Webpack, Parcel 或 Layer 来减小项目文件大小后重试
🤔真的是包过大导致的吗
但我想这不是导致编译失败的主要原因,更主要的原因是这里:编译过程载入next.config.js配置失败:
[2022-03-28 16:51:19] error - Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
[2022-03-28 16:51:19]
[2022-03-28 16:51:19] > Build error occurred
[2022-03-28 16:51:19] Error: Not supported
[2022-03-28 16:51:19] at Object.loadConfig (/root/workspace/node_modules/next/dist/server/config.js:70:78)
[2022-03-28 16:51:19] npm ERR! code ELIFECYCLE
[2022-03-28 16:51:19] npm ERR! errno 1
[2022-03-28 16:51:19] npm ERR! [email protected] build:next build && next-sitemap --config next-sitemap.config.js
[2022-03-28 16:51:19] npm ERR! Exit status 1
😁引起失败的根本原因
导致失败的原因是显而易见的:版本不兼容
腾讯云采用的NodeJS版本10.21.0,无法编译nextjs12.1.1的项目。至少需要12.22.0的版本,而我在开发环境的node版本就已经是 v16.13.0
了
[2022-03-28 16:50:45] npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":">=12.22.0"} (current: {"node":"10.21.0","npm":"6.14.4"})
[2022-03-28 16:50:45] npm WARN notsup Not compatible with your version of node/npm: [email protected]
[2022-03-28 16:50:45] npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":">=12"} (current: {"node":"10.21.0","npm":"6.14.4"})
[2022-03-28 16:50:45] npm WARN notsup Not compatible with your version of node/npm: [email protected]
[2022-03-28 16:50:45] npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":">=12"} (current: {"node":"10.21.0","npm":"6.14.4"})
[2022-03-28 16:50:45] npm WARN notsup Not compatible with your version of node/npm: [email protected]
[2022-03-28 16:50:45] npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":">=12"} (current: {"node":"10.21.0","npm":"6.14.4"})
[2022-03-28 16:50:45] npm WARN notsup Not compatible with your version of node/npm: [email protected]
[2022-03-28 16:50:45] npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":">= 12.0.0"} (current: {"node":"10.21.0","npm":"6.14.4"})
[2022-03-28 16:50:45] npm WARN notsup Not compatible with your version of node/npm: [email protected]
解决方法
只能是期待腾讯云更新一下版本吧 。而NextJS本就是Vercel官方推出的框架,故不存在此类兼容性问题。
from notionnext.
看了下文档,nodejs的版本最高时支持到16.13的,但是不知道默认的版本为什么不能强制,如果选择api网关触发的是可以部署到16.13,不过我试了一下也没有成功。
开始怀疑时nextjs被限制了10.15,但是我新部署demo的可以部署到16.13,不知道什么情况。
另外这个触发方式在vercel属于哪一种触发部署?nextjs会定时拉取api?还是notion api会推送过来然后部署?
from notionnext.
采用这个serverless.yml部署是可以部署的,不过访问不到。
component: http
name: nextDemo
inputs:
src:
dist: ./
hook: npm run build
exclude:
- .env
faas:
runtime: Nodejs16.13
framework: nextjs
name: ${name}
apigw:
protocols:
- http
- https
app: notion
from notionnext.
开始怀疑时nextjs被限制了10.15,但是我新部署demo的可以部署到16.13,不知道什么情况。
按照官方文档的说明似乎默认是10.15的node版本 ,要在环境变量中配置node版本。
而且只要在环境变量中增加一堆key/value配置即可
另外这个触发方式在vercel属于哪一种触发部署?nextjs会定时拉取api?还是notion api会推送过来然后部署?
Vercel是自动触发的:利用github的hook特性。当代码有更新时会自动通知vercel平台。
而文章的动态更新则是利用NextJS本身增量式的网站渲染:ISR特性
from notionnext.
我在后面换了其他版本的node测试仍然不行,原因应该是没有写入的权限,这个是平台的问题,腾讯的ssr只有对/tmp的写入权限,但是nextjs要向.next文件夹写入一个BUID,造成无法部署,所以说的对还是vercel吧。
之所以想换腾讯的,主要还是国内的访问速度上,部署的时候有海外加速,所以还蛮合适的。😄
from notionnext.
优化国内的访问速度确实很重要,这个问题我持续关注一下,找找其他解决方案。
from notionnext.
嗯,我用上面得手动部署了一下,是可以部署,只不过还是报错,应该是文件写入的问题。
from notionnext.
部署调用失败的日志
日志:
START RequestId: 0a6fc635c0d72ed3e19ce67ce8483094
ready - started server on 0.0.0.0:9000, url: http://localhost:9000
Init Report RequestId: 0a6fc635c0d72ed3e19ce67ce8483094 Coldstart: 128ms (PullCode: 0ms InitRuntime: 1ms InitFunction: 127ms) Memory: 512MB MemUsage: 17.36MB
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
[Error: EROFS: read-only file system, unlink '/var/user/.next/BUILD_ID'] {
errno: -30,
code: 'EROFS',
syscall: 'unlink',
path: '/var/user/.next/BUILD_ID'
}
ERROR RequestId: 0a6fc635c0d72ed3e19ce67ce8483094 Result: {"errorCode":-1,"errorMessage":"Process exited unexpectedly.","statusCode":439}
END RequestId: 0a6fc635c0d72ed3e19ce67ce8483094
Report RequestId: 0a6fc635c0d72ed3e19ce67ce8483094 Duration: 1469ms Memory: 512MB MemUsage: 117.74MB
from notionnext.
我在后面换了其他版本的node测试仍然不行,原因应该是没有写入的权限,这个是平台的问题,腾讯的ssr只有对/tmp的写入权限,但是nextjs要向.next文件夹写入一个BUID,造成无法部署,所以说的对还是vercel吧。
确实如此,腾讯云函数环境不支持除开/tmp目录以外的文件读写。
from notionnext.
嗯,比较奇怪的是我用官方的demo部署是可以部署的,但是部署这个就不行了,日志也不详细,所以说没办法。
from notionnext.
修改启动脚本代码迁入/tmp目录,可以避开目录无法写入的问题:
[Error: EROFS: read-only file system, unlink '/var/user/.next/BUILD_ID'] {
相关脚本
scf_bootstrap
#!/bin/bash
pIDa=`/usr/sbin/lsof -i :9000|grep -v "PID" | awk '{print $2}'`
if [ "$pIDa" != "" ];
then
echo "1"
else
cp -r . /tmp
cd /tmp
export PORT=9000
/var/lang/node16/bin/node start.js
#node ./start.js
fi
start.js
#!/var/lang/node16/bin/node
console.log(__dirname)
const { nextStart } = require('next/dist/cli/next-start')
nextStart(['-p', '9000', '--hostname', '0.0.0.0'])
调用顺利
访问失败:
from notionnext.
看来是没戏了,估计路由也是问题很大,重点应该还是匹配度不够了。
from notionnext.
即便部署在腾讯云,也无法加快加载notion的内容,所以并不会快多少吧?
from notionnext.
即便部署在腾讯云,也无法加快加载notion的内容,所以并不会快多少吧?
notion的部署是拉取到本地渲染的,相当于静态的博客。
from notionnext.
Related Issues (20)
- 4.4.3新版本有些元数据的问题 HOT 1
- 【Jupyter笔记】能否增加jupyter支持?
- 【Link配置】Notion添加了LINK配置、但没生效 HOT 2
- 更新版本4.4.3后文章和公告字体变成默认字体了 HOT 1
- [本地运行错误] 1 of 3 unhandled errors Unhandled Runtime Error HOT 1
- 【编译失败】本地可以成功build,但是vercel会报 Minified React error 错误 HOT 1
- 【FONT_URL】为什么没有使用镜像地址呢,导致访问的时候很慢。 HOT 1
- 【Excel导入】从 Excel 复制日期粘贴进 date 字段后,会导致 notion-next 无法加载数据表
- 【页面报错】添加gittalk后首页正常但点进文章报错client-side-exception-occurred HOT 2
- Notion-Config中的分享图标配置(POST_SHARE_SERVICES不生效 HOT 2
- Fork 项目之后在 vercel 部署出现的错误
- 【gitbook 主题】文章详情加入封面图 HOT 3
- 【教程】分支部署能出个教程吗? HOT 1
- HEO主题的英雄区(首页顶部大卡),点击链接无法修改 HOT 1
- 【新主题】创建新主题教程或者新增一个主题Stack HOT 1
- 【评论插件】页底红字:Utterance HOT 2
- 【文章阅读量】请问是否新增支持每个文章下的阅览量监控、 HOT 1
- 【quote 块】第一行为空行时渲染为空
- 【Siyuan思源笔记】能否增加siyuan私有笔记的平台? HOT 2
- 【Chatbase插件】无法显示右下角的聊天按钮
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from notionnext.