npm module not found because resolved as fully specified

March 27, 2024

© 2024 borui. All rights reserved. This content may be freely reproduced, displayed, modified, or distributed with proper attribution to borui and a link to the article: borui(2024-03-27 20:25:26 +0000). npm module not found because resolved as fully specified. https://borui/blog/2024-03-27-en-npm-building-error-failed-to-resolve.
@misc{
  borui2024,
  author = {borui},
  title = {npm module not found because resolved as fully specified},
  year = {2024},
  publisher = {borui's blog},
  journal = {borui's blog},
  url={https://borui/blog/2024-03-27-en-npm-building-error-failed-to-resolve}
}

Some may have encountered this issue

Module not found: Error: Can't resolve './xxx' in '/yourprojectdirectory/src' Did you mean 'xxx.js'? BREAKING CHANGE: The request './xxx' failed to resolve only because it was resolved as fully specified

one of the fix method

{
    test: /\.m?js/,
    resolve: {
      fullySpecified: false,
    },
}

or just add .js extensions where it was missing

import xxx from './yourprojectdirectory/src/xxx';

//change to this:
import xxx from './yourprojectdirectory/src/xxx.js';
  1. JahnoelRondon. (Jan 1, 2022 ). "type": "module" with React. [module with javascript mimetype, a '.mjs' file, or a '.js' file where the package.json contains '"type": "module"'] #11865. [Issue]. Github. https://github.com/facebook/create-react-app/issues/11865

  2. user3130985. (Feb 3, 2022 ). Webpack 5 in Ceate React App can't resolve not fully specified routes [question]. stackoverflow. https://stackoverflow.com/questions/70964723/webpack-5-in-ceate-react-app-cant-resolve-not-fully-specified-routes

  3. puppe82. (Dec 28, 2022). Webpack 5: Import fails to resolve with Module not found error #7114. [Issue]. Github. https://github.com/fullcalendar/fullcalendar/issues/7114