babel-loader@7.1.2需要webpack @ 2 ||的同行3但没有安装

时间:2017-10-14 09:10:34

标签: javascript reactjs npm babel-loader

我在安装所有node_modules时遇到此问题。这让我很疯狂。

  

babel-loader@7.1.2需要webpack @ 2 ||的同伴3但没有   安装。

这是我的package.json文件

{
  default: {
    actions: {/** ... */}
    getters: {/** ... */}
    mutations: {/** ... */}
    state: {/** ... */}
  }
}

我在这个项目中使用Public Declare Function SetCursorPos Lib "User32" (ByVal x As Long, ByVal y As Long) As Long Public Declare Sub mouse_event Lib "User32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long) Public Const MOUSEEVENTF_LEFTDOWN = &H2 Public Const MOUSEEVENTF_LEFTUP = &H4 Public Const MOUSEEVENTF_RIGHTDOWN As Long = &H8 Public Const MOUSEEVENTF_RIGHTUP As Long = &H10 Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub Generate_XL(start_row As Integer, end_row As Integer) Dim xlWorkbookNewFileName As String Dim i As Integer Dim cmt As Comment Set cmt = ActiveCell.Comment For i = start_row To end_row Dim wb As Workbook Dim wb1 As Workbook Dim FileName As String Dim FilePath As String FileName = Cells(i, 1).Value If Cells(i, 20) = "s0" Then Set wb = ThisWorkbook Set wb1 = Workbooks.Open("H:\PROJECT.xls") 'STEP_1 Worksheets("sheetA").Select ' max X = 1250 ' max Y = 1250 Application.DisplayAlerts = False SetCursorPos 1050, 350 'x and y position mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 Sleep 50 mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 IsTimeToStop = True Application.Wait (Now() + TimeValue("00:00:01")) Worksheets("Menu").Select SetCursorPos 150, 530 'x and y position mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 Sleep 50 mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 IsTimeToStop = True Application.Wait (Now() + TimeValue("00:00:01")) If cmt Is Nothing Then Application.Wait (Now() + TimeValue("00:00:01")) SendKeys "~" ' pataw <ENTER> End If IsTimeToStop = True Application.Wait (Now() + TimeValue("00:00:01")) SetCursorPos 150, 610 'x and y position mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 Sleep 50 mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 IsTimeToStop = True Application.Wait (Now() + TimeValue("00:00:01")) SetCursorPos 150, 650 'x and y position mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 Sleep 50 mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 IsTimeToStop = True Application.Wait (Now() + TimeValue("00:00:01")) 'STEP_2 SetCursorPos 505, 434 'x and y position mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 Sleep 50 mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 IsTimeToStop = True SendKeys "~" SendKeys "~" SendKeys "{RIGHT 5}" SendKeys "^c" IsTimeToStop = True Application.Wait (Now() + TimeValue("00:00:01")) 'SendKeys "%{ }N" ' = (ALT&tab) 'SendKeys "^a" 'SendKeys "^a" 'Range("l2").Select 'Cells(i, 12).Select ' ElseIf Cells(i, 20) = "a0" Then ' MsgBox ("REST") ' Else: Cells(i, 20) = "x2" Then ' MsgBox ("NOTHING) End If 'Select Next i End Sub 。所以我无法更改 webpack.config.js 文件。我该怎么办?

3 个答案:

答案 0 :(得分:4)

请阅读这篇文章。它描述了对等依赖是什么。

https://stackoverflow.com/a/34645112/2379376

这意味着您根本没有安装webpack,或者您安装了不同的版本(webpack 1.x)。但是这个插件需要版本2或3中的webpack才能正常运行。

你能做的是

npm install webpack -g

所以npm会在你的系统上安装最新版本的webpack。 但是现在,当其他加载器需要旧版本的webpack时,可能会出现其他对等警告。

答案 1 :(得分:2)

在节点环境以及开发中(作为开发依赖项)在全局全局安装Webpack。 webpack的主要功能是捆绑JavaScript文件以供浏览器使用。每次在开发时对index.js(npm的入口点)进行更改时,都必须运行webpack在bundle.js文件中进行更改,因此我们需要同时安装环境(即节点环境和开发环境) 运行以下命令以解决该问题:

npm install -g webpack@3.10.0
npm install --save-dev webpack@3.10.0

在这里,我将3.10.0用于webpack。您也可以使用4。我认为这会有所帮助。

答案 2 :(得分:1)

使用Webpack 4时

我遇到了同样的错误,但实际上我安装了webpack 4。为了解决这个问题,我使用了babel-loader documentation上的说明并安装了以下额外的库: babel-loader,@ babel / core和@ babel / preset-env

安装所有必需库的命令:

npm install -D babel-loader @babel/core @babel/preset-env webpack

package.json devDependencies在安装之前:

  "devDependencies": {
    "chai": "^4.1.2",
    "enzyme": "^3.2.0",
    "enzyme-adapter-react-16": "^1.1.0",
    "expect": "^22.0.3",
    "jest-junit": "^3.3.0",
    "jest-junit-reporter": "^1.1.0",
    "node-sass": "^4.9.2",
    "prop-types": "^15.6.0",
    "react-test-renderer": "^16.2.0",
    "redux-mock-store": "^1.4.0",
    "sass-loader": "^6.0.6",
    "webpack": "^4.25.1",
    "webpack-cli": "^3.1.2",
    "webpack-dev-server": "^3.1.10"
  }

安装后:

"devDependencies": {
  "@babel/core": "^7.1.6",
  "@babel/preset-env": "^7.1.6",
  "babel-loader": "^8.0.4",
  "chai": "^4.1.2",
  "enzyme": "^3.2.0",
  "enzyme-adapter-react-16": "^1.1.0",
  "expect": "^22.0.3",
  "jest-junit": "^3.3.0",
  "jest-junit-reporter": "^1.1.0",
  "node-sass": "^4.9.2",
  "prop-types": "^15.6.0",
  "react-test-renderer": "^16.2.0",
  "redux-mock-store": "^1.4.0",
  "sass-loader": "^6.0.6",
  "webpack": "^4.25.1",
  "webpack-cli": "^3.1.2",
  "webpack-dev-server": "^3.1.10"
}

希望有帮助