部署到Heroku期间的vite错误
我的文件夹结构:
我的脚本:
"scripts": {
"start": "node main.mjs",
"dev": "NODE_ENV='development' npx nodemon main.mjs",
"build": "cd client && yarn build",
"install-client": "cd client && yarn",
"heroku-postbuild": "yarn install-client && yarn build"
}
client/package.json
"dependencies": {
...
},
"devDependencies": {
...
"@vitejs/plugin-vue": "^2.3.1",
"typescript": "~4.6.3",
"vite": "^2.9.1",
"vue-tsc": "^0.33.9"
}
错误:/bin/sh:1:vue-tsc:找不到
我的猜测是客户端上的 devDepentencies
没有被获取。但是我没有将 node_env
设置为 production
,因此不知道为什么没有获取它们。
将所有 DevDepentencies
移动到依赖项
一个好主意?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这很可能是由两个问题之一引起的:
以便为应用程序创建一个较小的slug slug尺寸,而Heroku的buildpack会从包装中删除DevDependencies。构建的结尾,以便SLUG仅包括在运行时列出的依赖项。
禁用此依赖项修剪,
您可以通过运行:或,对于纱线来
但是如果是这种情况,并且在运行时也使用丢失的依赖项,则应在
依赖项
而不是下列出。 DevDepentencies
。Heroku,默认情况下使用
NPM CI
而不是npm i
。因此,另一个选项是通过:禁用缓存:
值得检查您已在软件包中指定了正确的npm和node版本。并且您已承诺
package-lock.json
或yarn.lock
。This is likely caused by one of two issues:
In order create a smaller slug size for apps, the Heroku's buildpack will prune out the devDependencies from the package.json at the end of the build, so that the slug will only include the dependencies that are listed at runtime.
You can disable this dependency pruning, by running:
Or, for Yarn
But if this is the case, and the missing dependency is also used at runtime, then it should be listed under
dependencies
rather thandevDependencies
.Heroku, by default uses
npm ci
instead ofnpm i
. So another option would be to switch this back, with:And to disable the cache:
And worth also checking that you've specified the right NPM and Node version in your package.json (under
engines
). And that you've committed either apackage-lock.json
oryarn.lock
.在 @lissy93的解释的灵感中,那些试图用vite将Vue 3应用程序部署到Heroku的人。请按照此处的操作 https://www.codementor.io/@ravianand1988/easily-4-steps-to-countinous-deliver-delivery-auto-auto-auto-deploy-vue-vue-js-js-js-app-onapp-on-heroku-heroku-heroku-heroku-heroku-xljk9777777777pq (忽略 @vue/cli安装和vue-cli-service脚本),然后
在heroku设置中设置,因为您是从github连接了仓库。然后将其在package.json中的脚本标签中放置,
然后再次运行您的部署。
With inspiration from @Lissy93's explanation, For those trying to deploy Vue 3 app with Vite to Heroku. Follow the instruction here https://www.codementor.io/@ravianand1988/easily-4-steps-to-continuous-delivery-auto-deploy-vue-js-app-on-heroku-xljk977pq (ignore the @vue/cli install and the vue-cli-service scripts) then set
in your heroku settings given that you're connecting your repo from github. Then have this in your scripts tag in package.json
Then run your deployment again.