我是新手,首先,我实际上不知道我需要什么样的结构。
我需要构建多个应用程序,但其中一些依赖于相同的组件。
到目前为止效果很好,但我认为混合了一些东西
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<script type="module" crossorigin src="/assets/modules/modules\\VPlayerList\\index-74e8dd8e.js"></script>
<link rel="modulepreload" crossorigin href="/assets/js/main-a0df4ea4.js">
<link rel="stylesheet" href="/assets/main.44382b18.css">
</head>
<body>
<div id="app"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
参考资料错误,我错过了什么?
忘记附上vite配置:
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import path, { resolve } from 'path'
import glob from 'glob';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), …Run Code Online (Sandbox Code Playgroud) 我尝试克隆一个项目并运行npm install并遇到此错误:
npm ERR! code ETARGET
npm ERR! notarget No matching version found for @babel/traverse@^7.14.0.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of '@babel/helper-module-transforms'
npm ERR! notarget
Run Code Online (Sandbox Code Playgroud)
我已经在谷歌上搜索并找到了一些答案,其中用户遇到了 babel 模块的问题,所有者将其重定向到这里:https ://gist.github.com/hzoo/df94af2d2ec48696e683b772c775aa67
我们为我们公司的 npm 包使用了代理,尽管我将其从 package.json 中删除以测试问题是否是由于该问题引起的,但仍然遇到了同样的问题。
npm cache clean --force
npm cache verify
npm config rm proxy
npm config …Run Code Online (Sandbox Code Playgroud) 我几乎搜索了谷歌中的每个主题,但看起来它随着配置和版本的变化而变化。
我在导入 ES6 时遇到问题。我做了我能做的一切,我检查了 ts-jest 和 jest github issues 以及整个 stackoverflow,但无法完成。也许我忘记了什么?我仍然收到此错误:
SyntaxError: Cannot use import statement outside a module
我真的不知道还能做什么...
我的 babel.config.js
module.exports = api => {
const isTest = api.env('test');
// You can use isTest to determine what presets and plugins to use.
return {
presets: [
[
'@babel/preset-env',
'@babel/preset-typescript',
{
targets: {
node: 'current',
},
},
],
],
env: {
test: {
plugins: [
"transform-es2015-modules-commonjs"
]
}
}
};
};
Run Code Online (Sandbox Code Playgroud)
笑话配置.js
module.exports = {
preset: 'ts-jest',
rootDir: "./", …Run Code Online (Sandbox Code Playgroud)