gpt4 book ai didi

Javascript systemJS 错误找不到模块

转载 作者:行者123 更新时间:2023-12-03 04:06:14 28 4
gpt4 key购买 nike

我有一个没有安装 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);
});

我做错了什么?

最佳答案

您的问题可能是由于您错过了 configure 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 - 它自动处理配置部分。

关于Javascript systemJS 错误找不到模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44541812/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com