加载"npm:babel-core@5.5.6/browser.js"时出错



我已经安装了NPM和JSPM软件包,但是当我尝试运行代码时,我会在浏览器中遇到以下错误。

错误加载" npm:babel-core@5.5.5.6/browser.js"http://localhost:9000/jspm_packages/npm/babel-core@5.5.5.6/browser.js.js错误加载" npm:babel-core@5.5.6/browser.js",来自" npm:babel-core@5.5.5.6",at http://localhost:9000/jspm_packages/npm/babel-core@5.5.5.6。JS找不到:http://localhost:9000/jspm_packages/npm/babel-core@5.5.5.6/browser.js.js(警告:使用的非eRror使用(

NPM文件夹具有browser.js文件,但我仍然会遇到上述错误。下面是我的JSPM包装文件夹结构和包装文件的快照。

JSPM包装文件夹

package.json

"devDependencies": {
"almond": "^0.3.2",
"babel-core": "^5.8.38",
"chai": "^2.2.0",
"check-build": "^1.5.0",
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-requirejs": "~0.4.4",
"grunt-serve": "^0.1.6",
"jsdoc": "^3.3.0-beta3",
"jspm": "^0.15.3",
"karma": "^0.12.31",
"karma-babel-preprocessor": "^5.1.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^0.1.8",
"karma-cli": "0.0.4",
"karma-coverage": "^0.3.1",
"karma-jspm": "^1.1.4",
"karma-mocha": "^0.1.10",
"karma-mocha-reporter": "^1.0.2",
"karma-sinon": "^1.0.4",
"load-grunt-config": "^0.7.2" },
"jscsConfig": {
"esnext": true},
"jspm": {
"directories": {
  "test": "test"
},
"devDependencies": {
  "babel": "npm:babel-core@^5.1.13",
  "babel-runtime": "npm:babel-runtime@^5.1.13",
  "core-js": "npm:core-js@^0.9.4"
}

我尝试卸载NPM并再次安装它,但似乎不起作用。请帮助我解决这个问题。预先感谢。

配置文件看起来像:

System.config({
  "baseURL": "/",
  "transpiler": "babel",
  "babelOptions": {
   "optional": [
   "runtime"
    ]
  },
  "paths": {
    "github:*": "jspm_packages/github/*.js",
    "npm:*": "jspm_packages/npm/*.js",
    "*": "*.js"
   },
  "defaultJSExtensions": true
   });
System.config({
  "map": {
    "babel": "npm:babel-core@5.5.6",
    "babel-runtime": "npm:babel-runtime@5.5.6",
    "core-js": "npm:core-js@0.9.15",
    "github:jspm/nodelibs-process@0.1.1": {
      "process": "npm:process@0.10.1"
     },
    "npm:babel-runtime@5.5.6": {
    "process": "github:jspm/nodelibs-process@0.1.1"
     },
    "npm:core-js@0.9.15": {
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "process": "github:jspm/nodelibs-process@0.1.1",
      "systemjs-json": "github:systemjs/plugin-json@0.1.0"
      }
  }
});

我认为,问题在那里:

"defaultJSExtensions": true

它是弃用的设置,文档推荐为每个软件包指定此类行为。

原因是某人写import "moduleName"和某人import "moduleName.js"。设置修复了第一个情况,始终将.js添加到模块的末端。正如您可以从错误消息中看到的那样,SystemJS正在尝试加载browser.js.js,因此您应该为babel软件包选项指定defaultExtension: false以防止.js.js问题。

相关内容

  • 没有找到相关文章

最新更新