Я создал компонент React и пытался создать его пакет и опубликовать его.
Я тестировал его по ссылке NPM, а также установлена NPM, но после компиляции он всегда дает ошибку :: Модуль не найден . Даже если он присутствует в модулях узлов.{
"name": "field-input",
"version": "0.0.1",
"description": "Input Field Component",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsup",
"lint": "tsc"
},
"keywords": [
"react",
"component",
"input",
"field"
],
"author": "fastkit",
"license": "ISC",
"peerDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"dependencies": {
"lodash": "^4.17.21",
"lucide-react": "^0.475.0"
},
"devDependencies": {
"@tailwindcss/postcss": "^4.0.6",
"@tsconfig/recommended": "^1.0.8",
"@types/lodash.debounce": "^4.0.9",
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"autoprefixer": "^10.4.20",
"esbuild": "^0.25.0",
"esbuild-css-modules-plugin": "^3.1.4",
"postcss": "^8.5.2",
"tailwindcss": "^4.0.6",
"tsup": "^8.3.6",
"typescript": "^5.7.3"
}
}
dtsconfig.ts
{
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"strictNullChecks": true,
"target": "ESNext",
"moduleResolution": "node",
"module": "ESNext",
"declaration": true,
"jsx": "react-jsx",
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules"]
}
dtsup.config.ts
import { defineConfig } from "tsup";
export default defineConfig({
entry: ["src/index.ts"],
format: ["esm", "cjs"],
minify: true,
dts: true,
outDir: "dist",
sourcemap: true,
clean: true,
});
/src/index.ts
import "./index.css";
import FieldInput from "./FieldInput";
export default FieldInput;
/src/index.tsx
React Component
использование
"use client"
import FieldInput from "field-input";
export default function Home() {
return (
);
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... -not-found
Создан пакет NPM, но не может загружать :: Модуль не найден: ⇐ Javascript
Форум по Javascript
-
Anonymous
1739616003
Anonymous
Я создал компонент React и пытался создать его пакет и опубликовать его.
Я тестировал его по ссылке NPM, а также установлена NPM, но после компиляции он всегда дает ошибку :: [b] Модуль не найден [/b]. Даже если он присутствует в модулях узлов.{
"name": "field-input",
"version": "0.0.1",
"description": "Input Field Component",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsup",
"lint": "tsc"
},
"keywords": [
"react",
"component",
"input",
"field"
],
"author": "fastkit",
"license": "ISC",
"peerDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"dependencies": {
"lodash": "^4.17.21",
"lucide-react": "^0.475.0"
},
"devDependencies": {
"@tailwindcss/postcss": "^4.0.6",
"@tsconfig/recommended": "^1.0.8",
"@types/lodash.debounce": "^4.0.9",
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"autoprefixer": "^10.4.20",
"esbuild": "^0.25.0",
"esbuild-css-modules-plugin": "^3.1.4",
"postcss": "^8.5.2",
"tailwindcss": "^4.0.6",
"tsup": "^8.3.6",
"typescript": "^5.7.3"
}
}
[b] dtsconfig.ts[/b]
{
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"strictNullChecks": true,
"target": "ESNext",
"moduleResolution": "node",
"module": "ESNext",
"declaration": true,
"jsx": "react-jsx",
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules"]
}
[b] dtsup.config.ts[/b]
import { defineConfig } from "tsup";
export default defineConfig({
entry: ["src/index.ts"],
format: ["esm", "cjs"],
minify: true,
dts: true,
outDir: "dist",
sourcemap: true,
clean: true,
});
[b]/src/index.ts[/b]
import "./index.css";
import FieldInput from "./FieldInput";
export default FieldInput;
[b]/src/index.tsx[/b]
React Component
[b] использование [/b]
"use client"
import FieldInput from "field-input";
export default function Home() {
return (
);
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79441342/created-npm-package-but-not-able-to-load-module-not-found[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия