<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/only-node-js-subpaths-with-no-restricted-imports-and-perfectionist-sort-imports-bqovdflgq" -->

---
title: Only Node.js subpaths with no-restricted-imports and...
description: A walkthrough of enforcing Node.js subpath imports as the sole import style in a codebase. It covers setting up subpath mappings in package.json for TypeScript...
canonical: https://daily.dev/posts/only-node-js-subpaths-with-no-restricted-imports-and-perfectionist-sort-imports-bqovdflgq
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Only Node.js subpaths with no-restricted-imports and perfectionist/sort-imports | daily.dev
og:description: A walkthrough of enforcing Node.js subpath imports as the sole import style in a codebase. It covers setting up subpath mappings in package.json for TypeScript...
og:url: https://daily.dev/posts/only-node-js-subpaths-with-no-restricted-imports-and-perfectionist-sort-imports-bqovdflgq
og:image: https://api.daily.dev/og/posts/bqoVDFlGQ.png
og:image:alt: Only Node.js subpaths with no-restricted-imports and perfectionist/sort-imports
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Only Node.js subpaths with no-restricted-imports and perfectionist/sort-imports

**[John Reilly](https://daily.dev/sources/johnnyreilly)** · 4 min read · 2 upvotes · 0 comments

## Summary

A walkthrough of enforcing Node.js subpath imports as the sole import style in a codebase. It covers setting up subpath mappings in package.json for TypeScript and runtime resolution, using ESLint's no-restricted-imports rule to block relative and alias-style imports, and using the perfectionist/sort-imports rule to keep import groups consistently ordered. The author acknowledges the approach is opinionated and may not suit every team.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://johnnyreilly.com/only-node-subpaths-with-no-restricted-imports-and-perfectionist-sort-imports>

## Similar posts on daily.dev

- [Enforce TypeScript Architecture Boundaries via AST Import Graphs](https://daily.dev/posts/enforce-typescript-architecture-boundaries-via-ast-import-graphs-3k2xiuqvu) · SitePoint · 1 upvotes · 0 comments
- [Automatic Import Sorting with ESLint and simple-import-sort](https://daily.dev/posts/automatic-import-sorting-with-eslint-and-simple-import-sort-ren0cfi9e) · Atomic Spin · 0 upvotes · 0 comments
- [NestJS Module Boundaries That Survive Growth](https://daily.dev/posts/nestjs-module-boundaries-that-survive-growth-bzh5p5uw6) · Medium · 2 upvotes · 2 comments
- [Ways to Improve Node.js Loader Performance](https://daily.dev/posts/ways-to-improve-node-js-loader-performance-mo7ywupjt) · AppSignal · 6 upvotes · 0 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#nodejs](https://daily.dev/tags/nodejs), [#typescript](https://daily.dev/tags/typescript)

[View this post on daily.dev](https://daily.dev/posts/only-node-js-subpaths-with-no-restricted-imports-and-perfectionist-sort-imports-bqovdflgq)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Only Node.js subpaths with no-restricted-imports and perfectionist/sort-imports","url":"https://daily.dev/posts/only-node-js-subpaths-with-no-restricted-imports-and-perfectionist-sort-imports-bqovdflgq","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/only-node-js-subpaths-with-no-restricted-imports-and-perfectionist-sort-imports-bqovdflgq"},"datePublished":"2026-03-16T17:43:23.043Z","dateModified":"2026-03-16T17:43:42.516Z","description":"A walkthrough of enforcing Node.js subpath imports as the sole import style in a codebase. It covers setting up subpath mappings in package.json for TypeScript...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/aeb77f9c3d643af932dc5bcea12911b1?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/aeb77f9c3d643af932dc5bcea12911b1?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"John Reilly","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"John Reilly","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/c1915bb9b8334d82853ec8e5f3a9532f","url":"https://daily.dev/sources/johnnyreilly"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/only-node-js-subpaths-with-no-restricted-imports-and-perfectionist-sort-imports-bqovdflgq","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"javascript,nodejs,typescript","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"John Reilly","item":"https://daily.dev/sources/johnnyreilly"},{"@type":"ListItem","position":3,"name":"Only Node.js subpaths with no-restricted-imports and perfectionist/sort-imports"}]}
```

