我正在尝试为我的开发服务器设置pm2,它似乎已启动,但是在进入端口3000的站点时,它说无法访问拒绝连接。我检查了我的pm2日志,并显示
SyntaxError:/var/www/html/ucdirectorapp/src/index.js:意外令牌(33:4) 0 | ucdirector-dev | 31 | ReactDOM.render( 0 | ucdirector-dev | 32 | 0 | ucdirector-dev | > 33 | 0 | ucdirector-dev | | ^ 0 | ucdirector-dev | 34 | ,document.getElementById('root')); 0 | ucdirector-dev | 35 |
所以我认为这与我的口译员有关。
我已经编译并创建了一个构建文件夹。
我已将解释器指向./node_modules/@babel/cli/bin/babel.js 甚至./node_modules/babel-cli/bin/babel-node.js。
我尝试重新安装babel-cli。我尝试删除我的node_modules并重新安装所有内容。
我尝试在全球范围内安装babel-cli。
//this is my pm2 config file
module.exports = {
apps: [{
name: "ucdirectorapp",
script: "./src/index.js",
watch: [
"./build",
"./public",
"./src"
],
watch_delay: 1000,
ignore_watch: ["node_modules"],
watch_options: {
"followSymlinks": false
},
env: {
name: 'ucdirector-dev',
NODE_ENV: 'development',
"PORT": 3000,
},
interpreter: "./node_modules/babel-cli/bin/babel.js"
}],
};
--
//my webpack config uses these presets and plugins for js
test: /\.(js|jsx)$/,
use: [
{
loader: "babel-loader",
options: {
presets:[ "@babel/preset-env", "@babel/preset-react"],
plugins: [
"@babel/plugin-syntax-dynamic-import", '@babel/plugin-proposal-class-properties'
]
}
}
],
---
//in my package.json these are the dependecies i'm using for babel
"@babel/plugin-proposal-class-properties": "^7.4.4",
"babel-plugin-async-to-promises": "^1.0.5",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1"
//this is what i have in dev dependecies
"@babel/core": "^7.4.5",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"babel-core": "^6.26.3",
"babel-loader": "^8.0.6",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
//and this is the script that I am using
"pm": "pm2 start config/server/pm2.config.js --watch",
我希望站点在端口3000上启动,并且语法错误将被删除。但我看到此语法错误。我猜想它不能收回反应类。
SyntaxError:/var/www/html/ucdirectorapp/src/index.js:意外令牌(33:4) 0 | ucdirector-dev | 31 | ReactDOM.render( 0 | ucdirector-dev | 32 | 0 | ucdirector-dev | > 33 | 0 | ucdirector-dev | | ^ 0 | ucdirector-dev | 34 | ,document.getElementById('root'));
答案 0 :(得分:0)
我发现生态系统.config.js可以使用解释器./node_modules/.bin/babel-node,但是在他们的文档中说,只有在以下环境中运行:
“ 叉子”模式
请记住,这些命令仅适用于fork_mode。如果要运行PM2群集,请参阅下面的替代方法。
您可以在其页面中查看所有信息。
http://pm2.keymetrics.io/docs/tutorials/using-transpilers-with-pm2#babel