Javascript systemJS错误找不到模块

用户8159753

我有一个安装 systemJS 的项目。

这是 package.json:

{
  "name": "mytest",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^15.5.4",
    "react-dom": "^15.5.4",
    "systemjs": "^0.20.13"
  },
  "devDependencies": {
    "react-scripts": "1.0.7"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

在 app.js 我已经这样做了:

import React, { Component } from 'react';
import './App.css';

var SystemJS = require('systemjs');

当我运行项目时,它给了我这个错误:

错误:找不到模块“。”

我正在按照此处的说明进行操作:

https://github.com/systemjs/systemjs

这部分:

var SystemJS = require('systemjs');

// loads './app.js' from the current directory
SystemJS.import('./app.js').then(function (m) {
  console.log(m);
});

我做错了什么?

之中

您的问题可能是由于您错过了配置systemjs 的事实 - 即指示它在哪里查找要加载的模块。

例如,配置可能如下所示:

System.config({
  baseURL: './lib',

  // Set paths your modules
  paths: {
    'angular': 'mode_modules/angular/angular.js',
    'angular-route': 'node_modules/angular-route/angular-route.js'
  }
});

如果你想跳过繁琐的配置部分——你可能想看看JSMP——它会自动处理配置部分。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章