错误:无法找到模块'../constants.js' - 如果pm2在启动脚本中运行 [英] ERROR: Cannot find module '../constants.js' - if pm2 is run in start script

查看:293
本文介绍了错误:无法找到模块'../constants.js' - 如果pm2在启动脚本中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


迁移到Azure App Service时,我的应用无法启动并抛出:


> NODE_ENV =生产pm2 start server.js 

internal / modules / cjs / loader.js:573
throw err;
^

错误:无法在Function.Module._resolveFilename中找到模块'../constants.js'
(internal / modules / cjs / loader.js:571:15 )
在Function.Module._load(internal / modules / cjs / loader.js:497:25)
在Module.require(internal / modules / cjs / loader.js:626:17)
at require(internal / modules / cjs / helpers.js:20:18)
at Object。< anonymous> (/home/site/wwwroot/node_modules/.bin/pm2:11:20)Module._compile上的
(内部/ modules / cjs / loader.js:678:30)
at Object.Module ._extensions..js(internal / modules / cjs / loader.js:689:10)
在Module.load(internal / modules / cjs / loader.js:589:32)
在tryModuleLoad( internal / modules / cjs / loader.js:528:12)
在Function.Module._load(internal / modules / cjs / loader.js:520:3)

package.json

  {
" name":" my-app",
" version" :" 1.0.0",
" description":"",
" main":" server.js",
" scripts":{
" start":" NODE_ENV = production pm2 start server.js",
" dev":" nodemon --ignore'。/ public'server.js"
},
" author":"",
" license":" ISC",
" dependencies":{
" pm2":" ^ 3.3.1"
...
},
" devDependencies" ;: {
" nodemon":" ^ 1.18.6",
}
}


我看到App Service全局安装了pm2,如果我注释掉我的开始脚本,它将选择  server.js  自动
然后工作,但为了更多的控制我真的想在pm2保留我自己的启动脚本。


任何想法?

谢谢



解决方案

您是否在Web应用程序的"应用程序设置"刀片中指定了自定义文件启动位置?与国家统计局p;





Hi,

While migrating to Azure App Service my app fails to start and throws:

> NODE_ENV=production pm2 start server.js

internal/modules/cjs/loader.js:573
    throw err;
    ^

Error: Cannot find module '../constants.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:571:15)
    at Function.Module._load (internal/modules/cjs/loader.js:497:25)
    at Module.require (internal/modules/cjs/loader.js:626:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/home/site/wwwroot/node_modules/.bin/pm2:11:20)
    at Module._compile (internal/modules/cjs/loader.js:678:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
    at Module.load (internal/modules/cjs/loader.js:589:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
    at Function.Module._load (internal/modules/cjs/loader.js:520:3)

package.json

{
  "name": "my-app",
  "version": "1.0.0",
  "description": "",
  "main": "server.js",
  "scripts": {
    "start": "NODE_ENV=production pm2 start server.js",
    "dev": "nodemon --ignore './public' server.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "pm2": "^3.3.1"
    ...
  },
  "devDependencies": {
    "nodemon": "^1.18.6",
  }
}

I saw App Service has pm2 installed globally, and if I comment out my start script it will pick the server.js automatically which then works, but for more control I really want to keep my own start script along pm2.

Any idea?
Thanks

解决方案

Did you specify your custom file start up location in the Application Settings blade for your web app? 



这篇关于错误:无法找到模块'../constants.js' - 如果pm2在启动脚本中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆