I'm using angular 2+, I have copy a custom package into my node_module directory like this node_module/@customPackage/forms so in my component code I import it like this import {blabla}from '@customPackage/forms'. but at the compilation time I still have an error saying "[ts] cannot find module @customPackage/forms".
I really don't know why I have that error. Please help. Thanks
您可以在package.json
文件中的dependencies
数组中写下包名称,然后点击npm install
.so 安装所有依赖项
Hi no you dont need to copy paste your package, The correct way to use your custom package into the angular application, is to link it like so:
STEPS :
1. inside your custom package folder:
yarn build
yarn link
:
this will display something like this(this is from my custom package) .
yarn link "my-package
": open your code editor, if you use vscode
you should see the package into node_modules
folder, with a small arrow on the right like so:
If you succeed on the above, you can now use your module like eg import { mymodule } from 'my-package
Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.