I have react+next and node js project and I want to deploy that project at heroku. That is the structure of my project:- enter image description here

and my package.json file is enter image description here if I add "Start": "next start" only the frontend works and if I changed it "Start": "tsc -p server/tsconfig.json -watch && node server.js" it's gave me the error.

error is :-enter image description here

推荐答案

Heroku安装了package.json中列出的dependenciesdevDependencies之后,在运行npm start命令之前,所有devDependencies都会被删除.因此,如果您在devDependencies下安装了typescript,并且您的项目在运行时需要它,那么将找不到它.为了防止修剪,将typescript移到dependencies.

另一个选项是通过设置以下配置变量,完全跳过修剪过程:

$ heroku config:set NPM_CONFIG_PRODUCTION=false YARN_PRODUCTION=false

或者将NODE_ENV环境变量设置为production以外的任何值(Heroku的默认值).

Node.js相关问答推荐

我的位置也移动时左右拖动谷歌 map

赫斯基添加命令已弃用?

GraphQL MongoDB Mongoose填充字段未获取多个类别

聚合发布/订阅消息

如何在MEVN堆栈中结合创建和更新表单流程?

使用NodeJS的DynamoDB中的BatchGetItem出现MultipleValidationError

Nestjs重写子类dto nodejs中的属性

在全局对象上声明的函数

Google App Engine 突然不允许我部署我的 node.js 应用程序

未捕获的错误: 只能用作 元素的子元素,永远不会直接呈现.请将您的 包裹在

将文件传递到 AWS lambdas(nodejs) + API 网关后重新上传文件

FirebaseCloudMessaging : PlatformException (PlatformException(null-error, Host platform returned null value for non-null return value., null, null))

使用 .pipe(res) 向客户端发送音频不允许您搜索?

fs.writefile 选项参数的可能值,尤其是只读文件的整数

异步函数 - 等待不等待promise

如何可靠地散列 JavaScript 对象?

Node.js `--nolazy` 标志是什么意思?

从 React(同构应用程序)进行 API 调用时出现Access-Control-Allow-Origin问题

- configuration.output.path:提供的值public不是绝对路径!使用 Webpack

大型项目的 NodeJS vs Play 框架