[英]PM2 Interpretor not using babel for my dev environment for react app
我正在嘗試為我的開發服務器設置 pm2,它似乎已啟動,但是在端口 3000 中訪問我的站點時,它說無法訪問它拒絕連接。 我檢查了我的 pm2 日志,它說
語法錯誤:/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 上運行,並刪除語法錯誤。 但我看到了這個語法錯誤。 我猜它不會重新識別反應類。
語法錯誤:/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'));
我發現生態系統.config.js 可以使用解釋器 ./node_modules/.bin/babel-node 但在他們的文檔中說只有當它運行在:
“分叉”模式
請記住,這些命令僅適用於 fork_mode。 如果你想運行一個 PM2 集群,請參考下面的替代方案。
您可以在他們的頁面中查看所有信息。
http://pm2.keymetrics.io/docs/tutorials/using-transpilers-with-pm2#babel
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.