[英]Javascript systemJS Error Cannot find module
I have a little not project where I have installed systemJS. 我在安装systemJS的地方没有项目。
Here is package.json: 这是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"
}
}
In app.js I have done this: 在app.js中,我这样做:
import React, { Component } from 'react';
import './App.css';
var SystemJS = require('systemjs');
When I run the project it's giving me this error: 当我运行项目时,它给了我这个错误:
Error: Cannot find module "." 错误:找不到模块“。”
I'm following the instructions here: 我正在按照这里的说明进行操作:
https://github.com/systemjs/systemjs https://github.com/systemjs/systemjs
This part: 这部分:
var SystemJS = require('systemjs');
// loads './app.js' from the current directory
SystemJS.import('./app.js').then(function (m) {
console.log(m);
});
What I'm I doing wrong? 我做错了什么?
Your problems could be due to the fact that you have missed to configure systemjs - that is instruct it where to look for modules to load. 您的问题可能是由于您错过了配置 systemjs的事实-指示它在哪里寻找要加载的模块。
For example the configuration can look something like this: 例如,配置可以如下所示:
System.config({
baseURL: './lib',
// Set paths your modules
paths: {
'angular': 'mode_modules/angular/angular.js',
'angular-route': 'node_modules/angular-route/angular-route.js'
}
});
If you would like to skip the tedious configuration part - you might want to look at JSMP - it takes care of configuration part automatically. 如果您想跳过繁琐的配置部分-您可能要看看JSMP-它会自动处理配置部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.