Ubuntu 18.04下已安装react-plaid-link仍报错:Module not found
Hey there, let's work through this frustrating error together. It's super common to run into module resolution issues even after installing a package, so here are the most likely fixes to try step by step:
1. Verify the package is actually installed in your project
- First, double-check you ran the install command in your project's root directory (not globally). Global packages don't get picked up by your project's dependency system.
- Open your
package.jsonfile and look forreact-plaid-linkin either thedependenciesordevDependenciessection. If it's missing, re-run the install command:
(Addnpm install react-plaid-link--save-devif you only need it for development) - You can also peek into your
node_modulesfolder—if there's noreact-plaid-linkdirectory there, the install didn't complete successfully.
2. Clear npm cache and reinstall dependencies
Corrupted cache or lock files are often the culprit here. Try these steps:
- Clear the npm cache:
npm cache clean --force - Delete the
node_modulesfolder andpackage-lock.jsonfile:rm -rf node_modules package-lock.json - Reinstall all dependencies from scratch:
npm install
3. Check Node.js/npm version compatibility
Your Node.js 10.13.0 and npm 6.11.2 are a bit outdated, but most older versions of react-plaid-link should support them. However:
- If you installed a newer version of
react-plaid-link, it might require a higher Node.js version. Try installing a compatible older version like:npm install react-plaid-link@^3.0.0 - Alternatively, upgrade npm to the latest stable version in the 6.x branch (since Node 10 doesn't support newer npm versions):
npm install -g npm@6.14.18
4. Confirm your import statement is correct
Linux systems are case-sensitive, so even a tiny typo can break things. Make sure your import looks exactly like this:
import { PlaidLink } from 'react-plaid-link';
Double-check for misspellings, incorrect capitalization, or extra characters.
5. Check webpack configuration (if using custom setup)
If you're not using a pre-built scaffold like Create React App, verify your webpack config is set up to resolve modules from node_modules. Ensure your resolve section includes node_modules:
module.exports = { // ... other config resolve: { modules: ['node_modules', path.resolve(__dirname, 'src')] } };
6. Restart your development server
Sometimes the dev server doesn't pick up new installed packages until you restart it. Kill the running server (usually with Ctrl+C) and re-run npm start to see if that fixes it.
If none of these steps work, it might be worth checking for dependency conflicts—run npm ls react-plaid-link to see if there are any nested versions or conflicts with other packages.
内容的提问来源于stack exchange,提问作者Nikul Panchal

