1000sj
SJ CODE
1000sj
전체 방문자
오늘
어제
  • 분류 전체보기
    • Algorithms
      • Crypto
    • Security
      • 네트워크
      • 보안
      • CTF
      • Exploit
    • System Programming
      • Operating System
      • Compiler
      • Device Driver
      • Emulator
      • Parrelel Processing
      • Assembly
    • Application Programming
      • Script
      • Android
    • Cloud Computing
      • Cloud Native
      • Public Cloud
      • Infrastructure
      • Database
      • DevOps
    • TroubleShooting
    • ETC
      • 문화 생활
      • 커뮤니티

인기 글

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
1000sj

SJ CODE

TroubleShooting

[Node] ERR_MODULE_NOT_FOUND

2021. 8. 22. 14:47

Problem

import module을 찾을 수 없음

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'e:\workspace\algorithms\javascript\algorithms\search\linear-search\linearSearch' imported from e:\workspace\algorithms\javascript\algorithms\search\linear-search\test.js
    at new NodeError (node:internal/errors:363:5)
    at finalizeResolution (node:internal/modules/esm/resolve:307:11)
    at moduleResolve (node:internal/modules/esm/resolve:742:10)
    at Loader.defaultResolve [as _resolve] (node:internal/modules/esm/resolve:853:11)
    at Loader.resolve (node:internal/modules/esm/loader:89:40)
    at Loader.getModuleJob (node:internal/modules/esm/loader:242:28)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:73:40)
    at link (node:internal/modules/esm/module_job:72:36) {
  code: 'ERR_MODULE_NOT_FOUND'

Solution 

before

import linearSearch from './linearSearch'

 

 

after

import { linearSearch } from './linearSearch.js' // 확장자 추가

export할 객체에 export 를 해줘야한다.

export function linearSearch(array, x) {
    const foundIndices = [];
    
    array.forEach((element, index) => {
        if (element == x) {
            foundIndices.push(index);
        }
    });

    return foundIndices;
}

 

 

 

 

  • Ref

https://ko.javascript.info/import-export#ref-4122

'TroubleShooting' 카테고리의 다른 글

Windows 10 설정이 열리지 않을 때  (0) 2022.03.03
[Flutter] Connection closed before full header was received, uri =  (0) 2021.09.05
Upgrade Gradle wrapper to 4.8.1 version and re-import the project  (0) 2021.07.13
org.jetbrains.annotations.NotNull >> javax.annotation.Nonnull  (0) 2021.07.02
[안드로이드스튜디오]Manifest merge failed  (0) 2021.06.19
    'TroubleShooting' 카테고리의 다른 글
    • Windows 10 설정이 열리지 않을 때
    • [Flutter] Connection closed before full header was received, uri =
    • Upgrade Gradle wrapper to 4.8.1 version and re-import the project
    • org.jetbrains.annotations.NotNull >> javax.annotation.Nonnull
    1000sj
    1000sj

    티스토리툴바