Storybook and Types - reactjs

I'm getting this error in a React project using another storybook project with typescript inside the company.
In npm start, I'm getting this error:
Could not find a declaration file for module '#myCompany/ui-components-library'. '/Users/pablo/Documents/git-projects/forward-admin-tools/node_modules/#myCompany/ui-components-library/dist/bundle.js' implicitly has an 'any' type.
Try `npm i --save-dev #types/myCompany__ui-components-library` if it exists or add a new declaration (.d.ts) file containing `declare module '#myCompany/ui-components-library';`
The problem is that I am using the first components from there.
When I try to install them, I'm getting this other error:
ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/#types%2fmyCompany__ui-components-library - Not found
npm ERR! 404
npm ERR! 404 '#types/myCompany__ui-components-library#*' is not in the npm registry.
Do I forget anything?
Please, I need some help with that.
The project has already been deployed to https://npmjs.com
Kind regards!

Related

How to fix - Could not find a declaration file for module '#okta/okta-react' - error?

I installed #okta/okta-react package in my application but it threw the following error?
Could not find a declaration file for module '#okta/okta-react'.
'.../node_modules/#okta/okta-react/dist/index.js' implicitly has an 'any' type.
Try `npm install #types/okta__okta-react` if it exists or add a new declaration (.d.ts)
file containing `declare module '#okta/okta-react';`ts(7016)
How to fix this error?
What I tried?
I checked this blog. I tried to implement this solution but my app does not have tsconfig.json.
EDIT 1:
I tried to install #types/okta__okta-react but got this error:
$ npm install #types/okta__okta-react
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/#types%2fokta__okta-react - Not found
npm ERR! 404
npm ERR! 404 '#types/okta__okta-react#latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
Seems like they do not have types yet. You will need to follow devs advice here https://github.com/okta/okta-oidc-js/issues/66#issuecomment-394574326
Change the node version
In my case got the [Module not found: Can't resolve] error it got resolved after changing the node version.
previous version = v12.4.0
Updated to = v15.8.0
try nvm use 15.8.0 (in terminal)

Could not find a declaration file for module, #types/...#latest' is not in the npm registry

I install react-pivottable then when I import this
import PivotTableUI from 'react-pivottable';
I am gettig this as error as vscode warning
Could not find a declaration file for module 'react-pivottable'.
'.../node_modules/react-pivottable/PivotTableUI.js' implicitly has an 'any' type.
Try `npm install #types/react-pivottable` if it exists or add a new declaration (.d.ts)
file containing `declare module 'react-pivottable';`ts(7016)
Then I type npm install #types/react-pivottable
But at this time I am getting this error as console output
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/#types%2freact-pivottable - Not found
npm ERR! 404
npm ERR! 404 '#types/react-pivottable#latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\tphusnua\AppData\Roaming\npm-cache\_logs\2020-07-28T08_48_48_808Z-debug.log
What should I do ? Thank You.
Another thing that you can do is mentioned in the error :(since you already tried npm install and it did not work)
Could not find a declaration file for module 'react-pivottable'.
'.../node_modules/react-pivottable/PivotTableUI.js' implicitly has an 'any' type.
Try `npm install #types/react-pivottable` if it exists or add a new declaration (.d.ts)
file containing `declare module 'react-pivottable';`ts(7016)
create a typings or type folder(name it as you want)
have a file created - decalaration.d.ts and in that file write declare module 'react-pivottable;
in tsconfig.json add "typeRoots": ["./typings","node_modules/#types"] <- path to your typings folder and also path to types in node_modules so that if types are present in node_modules it will be referred
Note : This can also be resolved by adding following property to tsconfig.json:
"noImplicitAny": false

How develop node modules locally using npm link in react project

I want to add my custom build botframework-webchat in reactproject
I have tried adding using npm link.I get the following Error
Vostro-270s:~/React/Botframework webchat/chatbot$ npm link ./BotFramework-WebChat-3
npm ERR! code EINVALIDTYPE
npm ERR! typeerror Error: Argument #2: Expected array but got string
npm ERR! typeerror at EventEmitter.install (/usr/local/lib/node_modules/npm/lib/install.js:190:3)
npm ERR! typeerror at Object.commandCache.(anonymous function) (/usr/local/lib/node_modules/npm/lib/npm.js:156:13)
npm ERR! typeerror at /usr/local/lib/node_modules/npm/lib/link.js:93:24
npm ERR! typeerror at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:282:31
npm ERR! typeerror at FSReqWrap.oncomplete (fs.js:152:21)
npm ERR! typeerror This is an error with npm itself. Please report this error at:
npm ERR! typeerror <https://npm.community>
npm ERR! A complete log of this run can be found in:
npm ERR! /home/.npm/_logs/2019-07-16T11_35_13_546Z-debug.log
I have My BotFramework-WebChat-3 and My React app in a folder.
I'm tring to integrate Microsoft Botframework in my react app.
https://github.com/microsoft/BotFramework-WebChat
* Hard: In your React website, incorporate a custom build of the Web Chat component *
The simplest approach is to clone (or fork) this repo, alter it, build it, then reference your local build in your project's package.json as follows:
dependencies: {
...
'botframework-webchat': 'file:/path/to/your/repo'
...
}
Running npm install will copy your local repo to node_modules, and import/require references to 'botframework-webchat' will resolve correctly.
You may also wish to go so far as to publish your repo as its own full-fledged, versioned npm package using npm version and npm publish, either privately or publicly.
Different projects have different build strategies, yours may vary considerably from the above. If you come up with a different integration approach that you feel would have broad application, please consider filing a pull request for this README.
try run npm link /path/to/your/repo and don't forget to remove node_modules from your custom repo

React Navigation npm install ERR fresh Expo Init #react-navigation/native#3.1.4

React Native Expo Users!
I am running into error on expo init with react-navigation (both blank & with tabs):
npm ERR! 404 '#react-navigation/native#3.1.4' is not in the npm registry.
I have been developing with React Native using Expo for several months now and have great success learning and solving errors along the way!
I took a holiday, came back to start a new project, and hit a wall with react-navigation#^3.0.0 - I have tried many solutions and nonwork.
I am using expo and npm to start a new project, both tabs and blank template have the react-navigation npm install issue:
expo init
? Choose a template: expo-template-tabs
? Choose which workflow to use: managed
✔ Please enter a few initial configuration values.
Read more: https://docs.expo.io/versions/latest/workflow/configuration · 100% completed
? Yarn v1.13.0 found. Use Yarn to install dependencies? No
[08:18:30] Extracting project files...
[08:18:31] Customizing project...
[08:18:31] Initialized a git repository.
[08:18:31] Installing dependencies...
npm WARN deprecated kleur#2.0.2: Please upgrade to kleur#3 or migrate to 'ansi-colors' if you prefer the old syntax. Visit <https://github.com/lukeed/kleur/releases/tag/v3.0.0\> for migration path(s).
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/#react-navigation%2fnative - Not Found
npm ERR! 404
npm ERR! 404 '#react-navigation/native#3.1.4' is not in the npm registry.
npm ERR! 404 Your package name is not valid, because
npm ERR! 404 1. name can only contain URL-friendly characters
npm ERR! 404 It was specified as a dependency of 'react-navigation'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/ddcjosiahl/.npm/_logs/2019-02-08T13_18_47_333Z-debug.log
[08:18:47] Process exited with non-zero code: 1
[08:18:47] Set EXPO_DEBUG=true in your env to view the stack trace.
I am trying options with no luck:
Cleared NPM cache
Tried Yarn
Install expo cli again
npm install --save react-navigation ... react-native, native, etc
npm install --save react-navigation
npm ERR! code E404
npm ERR! 404 Not Found: #react-navigation/native#3.1.4
Note: I have spent all day yesterday trying to get new projects to work. I did manage to get passed it by installing different versions of react-native, and cannot replicate...which then caused a mismatch of versions and app wouldn't load:*
****RNGestureHandlerButton:****
enter image description here
Why is react-navigation#^3.0.0 needing native#3.1.4 and how to solve?
Thanks!
Solved by editing root .npmrc file confirming I had:
registry=https://registry.npmjs.org/
My issue was related to having "_auth=".
Both npm and yarn now work with react-navigation and 404's I was getting.
Thanks #Munishkin & #Atin Singh
I had the same issue while upgrading from expo v31 to v32. Tried all what you have done with no luck. Finally, installing from github with npm install https://github.com/react-navigation/react-navigation-native solved the issue for me. I then installed react-navigation package separately and then all other required modules for my project.
I don't have the clear idea to what your exact problem is. So, I am assuming that you're not able to use React-navigation with expo.
Try using yarn for the whole process instead of npm.
Use yarn when expo asks to make a new project and then to install react-navigation use-
yarn add react-navigation
I used navigation yesterday and it worked perfectly for me.
This is weird, 'cause I just tried and it fetches react-navigation with all dependencies nicely. Actually if you load https://registry.npmjs.org/#react-navigation%2fnative url directly in your browser you should see the corresponding JSON schema. If it gives you 404 you might want to troubleshoot your DNS resolvers.

npm scoped packages and private registry

Our company has set up a private npm registry for our packages. We are trying to set up an angular2 application and all angular packages that are included (from the angular2 tutorial page) are scoped. The issue is while npm is set to our private registry, an npm install gives us this error message:
npm ERR! Linux 4.4.8-boot2docker
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v4.3.0
npm ERR! npm v2.14.12
npm ERR! code E404
npm ERR! 404 no such package available : #angular/core
npm ERR! 404
npm ERR! 404 '#angular/core' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'search-ui'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! Please include the following file with any support request:
npm ERR! /tmp/npm-debug.log
If I set it to the default npm registry, angular2 pulls fine but obviously fails when trying to download the private package.
I haven't determined whether this is an overall angular2 thing (some permissions in the package manager) or just all scoped packages (not sure what other scoped packages exist). I have, however, tried all kinds of things to get the full set of packages to install to no avail (such as using a git repo instead of a package version which works in only specific cases which is not acceptable). And this error comes when I try to deploy this into either a Docker container or run locally (mostly concerned about the container case).
Has anyone else ever run into this problem? As well I apologize if this a bit vague so feel free to post a comment if more information is needed.
As NPM says in the documentation, all private packages are scoped, and scopes can be associated to custom registries.
So, if your private package is #myPrivateScope/aPrivatePackage, your problem could be solved by adding the following line to the .npmrc file on the root of your project:
#myPrivateScope:registry=http://my.private.registry.com
Where the url after the equals sign is the address to your private registry.
You can find other ways to do this association and more information about it on https://docs.npmjs.com/misc/scope#associating-a-scope-with-a-registry

Resources