运行pm2日志错误SyntaxError:意外令牌 [英] run pm2 logs error SyntaxError: Unexpected token

查看:66
本文介绍了运行pm2日志错误SyntaxError:意外令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想查看我的项目的日志

I want to see logs of my project

步骤:

  1. 我克隆了一个套接字应用程序.然后我运行 npm install pm2 -g 来安装pm2

我运行 pm2 start

有效.它显示我的套接字应用程序的表格

It works. It display a table of my socket app

但是如果我运行 pm2日志来查看日志,则存在这样的错误:

But if I run pm2 logs to see logs, there exist error like this :

1|mycompany | C:\PROGRAM FILES\NODEJS\NPM.CMD:1
1|mycompany | (function (exports, require, module, __filename, __dirname) { :: Created by npm, please don't edit manually.
1|mycompany |                                                               ^
1|mycompany |
1|mycompany | SyntaxError: Unexpected token :
1|mycompany |     at new Script (vm.js:79:7)
1|mycompany |     at createScript (vm.js:251:10)
1|mycompany |     at Object.runInThisContext (vm.js:303:10)
1|mycompany |     at Module._compile (internal/modules/cjs/loader.js:657:28)
1|mycompany |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
1|mycompany |     at Module.load (internal/modules/cjs/loader.js:599:32)
1|mycompany |     at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
1|mycompany |     at Function.Module._load (internal/modules/cjs/loader.js:530:3)
1|mycompany |     at C:\Users\Chelsea\AppData\Roaming\npm\node_modules\pm2\lib\ProcessContainer.js:295:23
1|mycompany |     at C:\Users\Chelsea\AppData\Roaming\npm\node_modules\pm2\node_modules\async\internal\once.js:12:16

我尝试运行 npm install socket.io express --save npm install jquery --save ,这是相同的.上面有错误

I try to run npm install socket.io express --save and npm install jquery --save, it's the same. there exist error above

我该如何解决这个问题?`

How can I solve this problem? `

更新:

C:\ PROGRAM FILES \ NODEJS \ NPM.CMD 像这样:

:: Created by npm, please don't edit manually.
@ECHO OFF

SETLOCAL

SET "NODE_EXE=%~dp0\node.exe"
IF NOT EXIST "%NODE_EXE%" (
  SET "NODE_EXE=node"
)

SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js"
FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_CLI_JS%" prefix -g') DO (
  SET "NPM_PREFIX_NPM_CLI_JS=%%F\node_modules\npm\bin\npm-cli.js"
)
IF EXIST "%NPM_PREFIX_NPM_CLI_JS%" (
  SET "NPM_CLI_JS=%NPM_PREFIX_NPM_CLI_JS%"
)

"%NODE_EXE%" "%NPM_CLI_JS%" %*

推荐答案

您会在错误消息中看到:

As you can see in the error message:

1|mycompany | (function (exports, require, module, __filename, __dirname) { :: Created by npm, please don't edit manually.

尝试删除 C:\ PROGRAM FILES \ NODEJS \ NPM.CMD:1 文件中 {之后的:.

Try to remove : after { in C:\PROGRAM FILES\NODEJS\NPM.CMD:1 file.

更新:我注意到pm2正在尝试将 NPM.CMD 文件作为js模块执行.对于将Windows CMD文件作为js模块运行,这是不可能的.如果您在Windows上安装了Git,则可以尝试从 git-bash (这是一个类似于Linux的终端)上运行pm2.

Update: I noticed that pm2 is tring to execute the NPM.CMD file as a js module. That's not possible for running a windows CMD file as a js module. If you installed Git on your windows, you can try running the pm2 from the git-bash which was a Linux-like terminal.

更新您可以尝试其他人的答案

这篇关于运行pm2日志错误SyntaxError:意外令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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