I have created a custom npm package library, I have successfully created it and published on npm and then installed the package using npm install <my-package-name>.
And now I am facing issue on importing the package.When I import it in app.module.ts file its shows:
Cannot find module 'my-module-name' or its corresponding type declarations.
I have also tried by deleting the node-modules and package-lock.json files and then npm install but sadly it's not works.
Related
i have installed fontawesome by following these steps by visiting their website.
npm i --save #fortawesome/fontawesome-svg-core
npm install --save #fortawesome/free-solid-svg-icons
npm install --save #fortawesome/react-fontawesome
and now am getting this error
./node_modules/react-scripts/node_modules/#pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js
Error: ENOENT: no such file or directory, open 'C:\Users\HP\Desktop\practice site\javascript\REACT\Codingworld\node_modules\react-scripts\node_modules#pmmmwh\react-refresh-webpack-plugin\lib\runtime\RefreshUtils.js'
Help me to solve my error
Please try this one. I hope to solve it. if it solves please comment on my answer.
install font-awesome for react
The error message says that it's looking for a file RefreshUtils.js in the directory C:\Users\HP\Desktop\practice site\javascript\REACT\Codingworld\node_modules\react-scripts\node_modules#pmmmwh\react-refresh-webpack-plugin\lib\runtime but doesn't find it.
This file is part of the npm package #pmmmwh/react-refresh-webpack-plugin.
It could be that you previously installed this package, or that this package is a dependency for another package you're using (e.g. react-scripts).
Your question doesn't include sufficient information, such as the content of your package.json file, and specifying which command is giving the error.
There could be various reasons causing the error:
Running the command from the wrong folder
In this case, navigate to the correct folder in your terminal, then run the command.
Issues in your dependencies
In this case, given that you have a package.json file in your project folder, reinstall all your dependencies:
Delete the node_modules folder and the package-lock.json file
Run npm cache clean
Run npm install
Given that you're running the command from the correct folder and your dependencies are up-to-date, the error should go away.
I've been using npm install react-financial-charts successfully. However, I want to include this package locally instead (for reasons), so I checked out the master branch of react-financial-charts from Github. I now have two folders:
C:\Users\user\projects\react-financial-charts // fresh checkout from Github
C:\Users\user\projects\myproject // my project
Inside of my project, my package.json contains:
"dependencies": {
"react-financial-charts": "file:C:/Users/user/projects/react-financial-charts"
}
npm run dev will now encounter the compile error corresponding to a basic import statement import { BarSeries } from "react-financial-charts" in one of my files:
Module not found: Error: Can't resolve 'react-financial-charts' in 'C:\Users\user\projects\myproject\src\App'
So basically, the simple import statement which used to work (when I was doing npm install react-financial-charts), is now no longer working when I install the dependency from a local folder instead.
EDIT: I also tried these things that an answer below suggested, but I'm getting the exact same error message:
npm link ../react-financial charts
npm install ../react-financial charts
npm install --save ../react-financial charts
EDIT 2: This ended up working, thanks to the suggested answer below. The trick was I needed to npm update and npm install inside the dependency before linking.
cd react-financial-charts
npm link
cd ../myproject
npm link react-financial-charts
Method 1: Using npm-link
Go to C:\Users\user\projects\react-financial-charts in terminal:
npm link
Now, go to your project C:\Users\user\projects\myproject:
npm link react-financial-charts
Now, any changes to C:\Users\user\projects\react-financial-charts will be reflected in C:\Users\user\projects\myproject. Note that the link should be to the package name, not the directory name for that package.
Method 2: Saving local repo as npm-install
npm install --save ../path/to/mymodule
I have created this npm package. After installing it in another app and running it, I get the error:
Metro Bundler has encountered an internal error
This happens even if the project is a newly initialised one. What is wrong in my npm package?
Probably because in your index.js file you have
import App from "./src/App";
but there is no such file in your repo.
So I navigated to my project directory and run npm install scrollama intersection-observer. It installed the files on my HOME/node-modules instead of the project folder. During installation there were warnings, though:
npm WARN saveError ENOENT: no such file or directory, open '[my-home]/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '[my-home]/package.json'
npm WARN [my-user] No description
npm WARN [my-user] No repository field.
npm WARN [my-user] No README data
npm WARN [my-user] No license field.
So why did it installed globally (or, in my home instead of my project folder)?
Because your folder is not a valid npm install location as it could not find the package.json. to create that, just run:
npm init
You are not using npm init. npm init will initialize your node project and will make a package.json file. package.json file will store the information about the project such as project name, version, description and also the dependencies you download.
In your case there is no package.json file, because of this your packages are been installed to the home directory instead of current directory.
Also you can also use parameters like -g to install package globally (to the home directory) without any parameter, node will install the package in the current directory by default.
Installing locally: you can use the package inside your project.
Installing globally: you can use the package everywhere. Commands like nodemon are installed globally because you want to use these in every project.
When retrieving the dojo-util package from bower, the package is installed in a directory dojo-util/.., but when running the command line to create a custom build, it complains that the main.js file could not be found.
The file the compiler search for should be located in /util/build/main.js, but when installing with bower the dirname is /dojo-util/build/main.js.
Someone already had this problem ?
You can resolve this by instructing bower to install dojo-util as util:
bower install util=dojo-util#<version>
Or in bower.json's dependencies:
"util": "dojo-util#<version>"