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相关问答推荐

根据我的测试,为什么在编写Varint代码方面,NodeJS要比Rust快这么多?

GitLab 依赖扫描需要源代码中的 package-lock.json 才能执行

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

firebase/messaging 不提供名为 getToken 的导出

我怎样才能让`git`失败而不是要求提供凭据

MERN 堆栈项目中的 React [create-react-app] 正在提供依赖项

tsc:当我上传 React+next js 和 node 项目时,在 heroku 找不到

如何为一个网站实现这 2 个网址.即 www.administrator.sitename.com 和 www.sitename.com?

在本地运行 Cloud Functions 会出现错误functions.config() 不可用

使 pm2 登录到控制台

适用于 Windows 7 的 NodeJS

安全沙箱并执行用户提交的 JavaScript?

如何在客户端使用 node.js 模块系统

通过 POST 请求将数据从 node.js 服务器发送到 node.js 服务器

为什么我们要为 Angular 2.0 安装 Node.js?

Node.js -Firebase 服务帐户私钥不会解析

npm install 给出警告,npm audit fix 不起作用

如何在 NodeJS 中拆分和修改字符串?

在 Node.js 中混合使用 JavaScript 和 TypeScript

使用 Node-sass 缩小 CSS