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
'트러블슈팅' 카테고리의 다른 글
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 |