我正在尝试在Heroku上部署支持@ nuxt / typescript的Nuxt 2.10应用程序。
我已经使用heroku / nodejs Buildpack创建了一个Node应用程序容器,并配置了一个免费的dyno,如下所示:
web
yarn start
与此同时,我初始化了一个带有某些依赖项的新Nuxt项目,我在这里报告了package.json尽可能清晰。
脚本部分:
"scripts": {
"dev": "nuxt-ts",
"dev-debug": "npx --node-arg=--inspect nuxt-ts",
"build": "nuxt-ts build",
"start": "nuxt-ts start",
"generate": "nuxt-ts generate",
... some lint and test scripts...
"heroku-postbuild": "nuxt build"
},
之后是依赖关系:
"@nuxt/typescript": "^2.8.1",
"@nuxt/typescript-runtime": "^0.2.2",
"@nuxtjs/auth": "^4.8.4",
"@nuxtjs/axios": "^5.7.1",
"@nuxtjs/dotenv": "^1.4.1",
"@nuxtjs/proxy": "^1.3.3",
"@nuxtjs/pwa": "^3.0.0-0",
"cross-env": "^6.0.3",
"eventsource-polyfill": "^0.9.6",
"express": "^4.17.1",
"nuxt": "^2.10.2",
"nuxt-property-decorator": "^2.5.0",
...lots of stuffs here
最后是devDependencies:
"@nuxt/typescript-build": "^0.3.4",
"@nuxtjs/eslint-config": "^1.1.2",
"@nuxtjs/eslint-config-typescript": "^0.1.3",
"@nuxtjs/eslint-module": "^1.1.0",
"babel-eslint": "^10.0.3",
"babel-plugin-module-resolver": "^3.2.0",
"browser-env": "^3.2.6",
"eslint": "^6.5.1",
"eslint-config-prettier": "^6.4.0",
"eslint-plugin-nuxt": "^0.4.3",
"eslint-plugin-prettier": "^3.1.1",
"husky": "^3.0.9",
"node-sass": "^4.12.0",
"nodemon": "^1.19.4",
"require-extension-hooks": "^0.3.3",
"require-extension-hooks-babel": "^1.0.0",
"require-extension-hooks-vue": "^2.0.0",
"sass-loader": "^8.0.0"
... and others
幸运的是Heroku很棒,我报告了Heroku构建日志的关键部分:
Module parse failed: Unexpected character '@' (31:0)
File was processed with these loaders:
* ./node_modules/vue-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|
> @Component({
| components: {
|
@ ./pages/xxxx/index.vue?vue&type=script&lang=ts& 1:0-120 1:136-139 1:141-258 1:141-258
@ ./pages/xxxx/index.vue
@ ./.nuxt/router.js
@ ./.nuxt/index.js
@ ./.nuxt/client.js
@ multi ./.nuxt/client.js
FATAL Nuxt build error
at WebpackBundler.webpackCompile (node_modules/@nuxt/webpack/dist/webpack.js:5314:21)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async WebpackBundler.build (node_modules/@nuxt/webpack/dist/webpack.js:5263:5)
at async Builder.build (node_modules/@nuxt/builder/dist/builder.js:5597:5)
at async Object.run (node_modules/@nuxt/cli/dist/cli-build.js:100:7)
at async NuxtCommand.run (node_modules/@nuxt/cli/dist/cli-command.js:2575:7)
tput: No value for $TERM and no -T specified
╭─────────────────────────────╮
│ │
│ ✖ Nuxt Fatal Error │
│ │
│ Error: Nuxt build error │
│ │
╰─────────────────────────────╯
很明显,使用 yarn dev 在本地环境中开发广告制作应用程序就像一个魅力
我想说问题显然出在Heroku上,但我不知道如何解决。
真的很感谢任何帮助????
更新
只需更新package.json中的heroku-postbuild脚本,即可成功构建nuxt。
"heroku-postbuild": "nuxt-ts build"
但是现在,我遇到了一个新问题,我报告了构建日志:
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NPM_CONFIG_PRODUCTION=false
YARN_PRODUCTION=false
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): 12.11.1
engines.npm (package.json): unspecified (use default)
engines.yarn (package.json): 1.19.1
Resolving node version 12.11.1...
Downloading and installing node 12.11.1...
Using default npm version: 6.11.3
Resolving yarn version 1.19.1...
Downloading and installing yarn (1.19.1)...
Installed yarn 1.19.1
-----> Restoring cache
- node_modules
-----> Installing dependencies
Installing node modules (yarn.lock)
yarn install v1.19.1
[1/4] Resolving packages...
success Already up-to-date.
Done in 1.35s.
-----> Build
Detected both "build" and "heroku-postbuild" scripts
Running heroku-postbuild (yarn)
yarn run v1.19.1
$ nuxt-ts start
WARN No .env file found in /tmp/build_87.........xc/.
FATAL No build files found in /tmp/build_87.........xc/.nuxt/dist/server.
Use either `nuxt build` or `builder.build()` or start nuxt in development mode.
Use either `nuxt build` or `builder.build()` or start nuxt in development mode.
at VueRenderer._ready (node_modules/@nuxt/vue-renderer/dist/vue-renderer.js:4226:13)
at Server.ready (node_modules/@nuxt/server/dist/server.js:607:5)
at Nuxt._init (node_modules/@nuxt/core/dist/core.js:655:7)
tput: No value for $TERM and no -T specified
╭─────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ ✖ Nuxt Fatal Error │
│ │
│ Error: No build files found in │
│ /tmp/build_87.........xc/.nuxt/dist/server. │
│ Use either `nuxt build` or `builder.build()` or start nuxt in development mode. │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────╯
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed