I encountered an error while trying to import a module in my test application.
../fetchModule/index.js Module not found: Can't resolve './Myfetch' in '/Users/******/nodework/fetchModule'
Here is the folder structure:
https://i.sstatic.net/PXg2C.png
And here is the package.json file:
package.json
{
"name": "fetchmodule",
"version": "1.0.0",
"description": "a fetch module for our project",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "./node_modules/.bin/babel src --out-file index.js"
},
"peerDependencies": {
"react": "^16.6.6",
"react-dom": "^16.6.3",
"axios": "^0.19.0"
},
"author": "",
"license": "ISC",
"dependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"react": "^16.8.6",
"react-dom": "^16.8.6"
},
"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.4.4",
"axios": "^0.19.0"
}
}
index.js
import React, {Component} from 'react';
import Myfetch from './Myfetch';
export default class Fetch extends Component {
.......
}
MyFetch
import React, {Component} from 'react';
import axios from 'axios';
export default class MyFetch extends Component {
.....
}