我想查看我的项目的日志
步骤:
我克隆了一个套接字应用程序。然后我运行npm install pm2 -g
安装pm2
我运行pm2 start
有效。它显示我的套接字应用程序的表格
但是如果我运行pm2 logs
来查看日志,则存在这样的错误:
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
,这是相同的。上面有错误
如何解决此问题? `
更新:
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%" %*
答案 0 :(得分:0)
您会在错误消息中看到:
1|mycompany | (function (exports, require, module, __filename, __dirname) { :: Created by npm, please don't edit manually.
尝试删除:
文件中{
之后的C:\PROGRAM FILES\NODEJS\NPM.CMD:1
。
更新:
我注意到pm2正在尝试将NPM.CMD
文件作为js模块执行。对于将Windows CMD文件作为js模块运行,这是不可能的。
如果您在Windows上安装了Git,则可以尝试从git-bash
(这是一个类似Linux的终端)上运行pm2。