当前位置:   article > 正文

babel编译时出现:Error: Cannot find module ‘@babel/core‘_parsing error: [babel]: cannot find module '@babel

parsing error: [babel]: cannot find module '@babel/core

babel编译时出现:Error: Cannot find module ‘@babel/core’

ERROR in ./src/index.js
Module build failed (from ./node_modules/_babel-loader@8.1.0@babel-loader/lib/index.js):
Error: Cannot find module '@babel/core'
Require stack:
- D:\work\HBuilderXWorkspace\react\01.webpack-base\node_modules\_babel-loader@8.1.0@babel-loader\lib\index.js
- D:\work\HBuilderXWorkspace\react\01.webpack-base\node_modules\loader-runner\lib\loadLoader.js
- D:\work\HBuilderXWorkspace\react\01.webpack-base\node_modules\loader-runner\lib\LoaderRunner.js
- D:\work\HBuilderXWorkspace\react\01.webpack-base\node_modules\webpack\lib\NormalModule.js
- D:\work\HBuilderXWorkspace\react\01.webpack-base\node_modules\webpack\lib\NormalModuleFactory.js
- D:\work\HBuilderXWorkspace\react\01.webpack-base\node_modules\webpack\lib\Compiler.js
- D:\work\HBuilderXWorkspace\react\01.webpack-base\node_modules\webpack\lib\webpack.js
- D:\work\HBuilderXWorkspace\react\01.webpack-base\node_modules\_webpack-dev-server@3.11.0@webpack-dev-server\bin\webpac
k-dev-server.js
 babel-loader@8 requires Babel 7.x (the package '@babel/core'). If you'd like to use Babel 6.x ('babel-core'), you shoul
d install 'babel-loader@7'.
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (D:\work\HBuilderXWorkspace\react\01.webpack-base\node_modules\_babel-loader@8.1.0@babel-loade
r\lib\index.js:10:11)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26

babel-loader@8 requires Babel 7.x (the package '@babel/core'). If you'd like to use Babel 6.x ('babel-core'), you shoul d install 'babel-loader@7'.
Emmmm…应该是版本问题,那就去package.json里面改版本号好了。

  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.5",
  },
  • 1
  • 2
  • 3
  • 4

改完来,加载一下package.json的包,执行cnpm install或者npm install嗯,,

dependencies和devDependencies

  1. 使用环境:
    dependencies:生产环境下所依赖的 npm 包集合;
    devDependencies:开发和测试环境下所依赖的 npm 包集合;

  2. 单个包安装方式:
    dependencies:

    # 在与 package.json 同级目录下执行
    # —sava-prod 为默认安装模式
    # 安装以后会自动在 package.json 的 dependencies 下添加 <package-name>
    npm install <package-name> [—sava-prod]
    
    • 1
    • 2
    • 3
    • 4

    devDependencies:

    # 在与 package.json 同级目录下执行
    # 安装以后会自动在 package.json 的 devDependencies 下添加 <package-name>
    npm install <package-name> —sava-dev
    
    • 1
    • 2
    • 3
  3. 集成安装方式:
    dependencies:

    # 在与 package.json 同级目录下执行
    # 安装 dependencies 和 devDependencies 中的所有 npm 包
    npm install
    # 仅安装 dependencies 下的所有 npm 包
    npm install —production
    
    • 1
    • 2
    • 3
    • 4
    • 5

    devDependencies:

    # 在与 package.json 同级目录下执行
    # 安装 dependencies 和 devDependencies 中的所有 npm 包
    npm install
    
    • 1
    • 2
    • 3
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/279975
推荐阅读
相关标签
  

闽ICP备14008679号