styled-components/macro isn't working with CRA - styled-components

When i install a new create-react-app and add babel-plugin-styled-components and add displayName option to babel-plugin-macros.config.js it isn't adding readable classNames as in the documentation -> https://styled-components.com/docs/tooling#babel-macro.
Here is a repo with the configurations https://github.com/Futekov3216/CRA.git
P.S i dont want to eject

Today I myself faced such a problem. The problem lies in styled-components itself. Macro in styled does not work since version 5.2.2, and it is not known when it will be fixed. Simplest solution:
npm i styled-components#5.2.1

This problem still persists in styled-components v5.3.3. Visit this to know more about the issue. At this moment you can install styled-components#5.2.1 as mentioned by #mxpv for getting the Component's name along with generated classes.

The issue causing this problem has been resolved.
Ensure that the version of babel-plugin-styled-components has at least version 2.0.3 by installing the package (as a dev dependency). The macro should work with the latest version of Styled-Components.
npm install -D babel-plugin-styled-components
--or--
yarn add -D babel-plugin-styled-components

Related

How to prevent npm from resolving devDependencies on production install

I'm building a microservice app in a monorepo containing a bunch of microservices and a commons package. This commons package is never published to npm. (packages are managed with yarn workspaces)
Using parcel, the commons package is bundled into the production code, so I don't need to install it at run time.
Each microservice runs in its own docker container. So, when I build the docker container, Ideally, I'd want to ignore this "commons" dependency and install all the other ones. AFAIK, the only way to do this is to place the "commons" package in devDependencies.
However, it seems that even if I add it only to devDependencies and run npm i --only=production, npm still tries to resolve the package and still throws an ETARGET error.
Is there some way to completely ignore the devDependencies? My only other Idea is to write a script that removes the devDependencies field from the package.json before running npm install, but I wanted to ask here first to make sure I'm not missing anything.
There is a GitHub issue on the npm/cli repo tracking this issue here (#4967), where this behaviour is categorized as a bug.
So to answer your question, as far as the current status of the GitHub issue indicates, the intended behaviour is that devDependencies don't get attempted to be resolved in --production mode, and you shouldn't need to do anything extra to get this behaviour once the fix is made. I don't think you are missing anything.
The workaround you have thought of sounds reasonable to me.
On the GitHub issue, you can indicate "me too" with a thumbs up reaction (please don't spam the comments with "me too" comments).
To install packages only at production without devDependencies,
npm install --production
Docs about npm install is here.

node.js is not installed android studio gradle

guys,
I found the answer
node-js-is-not-installed
and I have the same problem
actually, I have nodejs
sudo apt-get install nodejs
Reading state information... Done
nodejs is already the newest version (8.10.0~dfsg-2ubuntu0.4)
.
but if I try to build I coach Gradle exception like
Node.js is not installed. Visit https://nodejs.org/en/download/ to install it.
Open File
unfortunately, steps by issues/3745 don't resolve it fo me
enter image description here
any help would be appreciated.
I had a identical problem earlier today. But I'm on a Mac. Same behaviour as you experienced.
I've try to reinstall node, and several rebuilding of my project but none of those worked.
In the end, I started over. Seems that the installation of the amplify cli did not went throught the previous time.
npm install -g #aws-amplify/cli
But I've come to another problem with the manifest.xml right after that. I think both are related...
And adding this to my manifest did the job : 'tools:replace="android:name"' (for reference if this problem follow : https://github.com/aws-amplify/amplify-android/issues/532 )
Run this in your project directory and then resync:
npx amplify-app --platform android
At least, this helped me
Did you install amplify using sudo? That has solved my problem.
Also using Mac OSX
Looks like you may not have proper write permissions on node_modules folder, use chmod 777 your_node_module_folder

Angular5 node js and npm installation problems

I have the latest versions of Node and NPM installed, using which I installed Angular/cli, but it's shooting me with following errors: angular/cli and npm versions not compatible with current version of node.
I suspect that I may(not) be installing out of the proper directory. But at this point, what else can I do? thanks.
Please check: Screenshot with details of the issue
I also faced a similar problem, but the solution was quite simple : my path was too long.
I shortened it a bit (two directories down) and then I did the install again with success.
Here are the reqs.
Both the CLI and generated project have dependencies that require Node 6.9.0 or higher, together with NPM 3 or higher.
You are using the latest node.js 9.2
you need to uninstall or rollback to 8.9 !!
Here is a guide
https://github.com/angular/angular-cli
Hope this solves it for you.
I faced a similar problem with angular/cli version not compatible with the current node version. This generally happens when you are upgrading from lower version of Angular to any other higher version.
You can try following steps:
npm outdated --> To list latest and current package details in local application.
npm update --> to update the local packages.
If it still doesn`t work,
Try deleting the 'node_modules' folder and install dependencies of fresh:
npm install
You can then check whether all packages, including the cli is not outdated.

Possible to "npm install" code changes added since last version number change?

This is a n00b npm question, as I'm just getting started here. Apologies.
I'm using the node-dbus npm module, whose latest version is 0.2.0. But I see that there have been code changes (one of which I want) added since the last version number change.
Do I need to ask the author of the package to update the version number so I can easily get the new stuff? Is it permissible/possible for me to go in and update the version number myself in the github repo? Or is there some clean way to set up the dependencies line in my package.json to get the stuff that has been added since the last version number change?
I see that it's supposed to be possible to use a "git remote url," but so far I'm unable to make that work. Is that what I should be doing? Is getting the version number updated the right direction?
Thanks for your help.
Steve
According to the official NPM documentation, you can install a package by:
npm install <githubname>/<githubrepo>[#<commit-ish>]
In your case, it should be:
npm install sidorares/node-dbus#<the-commit-that-contains-your-wanted-code>
You can add --save to the command to update package.json on the fly.
Please be aware that it is not a good practice to install modules from source code directly as it might not be a stable version.

Cannot find module dtrace-provider

I have a simple nodejs application that is throwing "Cannot find module './build/Release/DTraceProviderBindings'". I look it up online and it looks like that a lot of people are having the same problem when using restify on windows (which is my case, I'm using restify on windows 10). Apparently, dtrace-provider is a optional module for restify and there is no version of it for windows. So, what I tried so far:
Update node to v6.2.0;
Uninstall all modules and run npm install --no-optional;
Uninstall only restify and run npm install restify --no-optional;
And my most desperate move npm install dtrace-provider.
Everything I tried where found on github issues, I've seen same error on OSX users with other modules. Not sure what else to try.
Note: This exception does not stop my application, not even prints the error on the console, I just notice that this was happening using the debugger, in other words, my application runs fine, but this keeps happening on the background.
List of other modules I'm using:
"dependencies": {
"restify": "latest",
"request": ">=2.11.1",
"cheerio": ">=0.10.0",
"xml2js": ">=0.2.0",
"botbuilder": "^0.11.1",
"applicationinsights": "latest"
}
This worked for me after switching to Node 6.1 (and when re-installing node modules didn't work):
Install and save dtrace-provider
$ npm install dtrace-provider --save
Delete 'node_modules' folder
Re-install node modules
$ npm install
I found this thread before combining your attempts with another solution on the Github project issues for restify (https://github.com/restify/node-restify/issues/1093) and simplified best as possible.
I recently ran into this error as well on node 6.11.1.
I ran npm rebuild dtrace-provider and that resolved the problem.
The restify team followed an approach of trying to load the module by requiring it on a try/catch block. You should just ignore the exception.
I had success with the following (elaborate) sequence:
Adjust my path to not have spaces
rm -rf node_modules
rm -rf ~/Library/Caches/node-gyp/
npm cache clean --force
V=1 npm install -S dtrace-provider#0.8.8 --python=python2.7 (repeat this step, resolving as you go, until the install is completely successful … if it fails, check the version - I had rogue dtrace-provider#0.6.0 building at one point)
npm install
At this point everything should have installed cleanly, and I was congratulating myself on a job well done. Then I executed my code and still got the DTraceProviderBindings error. The cause was nested dependencies with the wrong version of dtrace-provider (especially bunyan).
To confirm, do npm list | grep dtrace -B6.
If there's anything lower than 0.8.8, edit package-lock.json, following the method in How do I override nested NPM dependency versions?. Replace requires with dependencies for dtrace-provider and update the version.
Back round to get everything clean: rm -rf node_modules
Then, again, npm install --python=python2.7
I had to iterate round npm list a few times because I thought I'd caught everything and I hadn't.
The key points were to use the required version of python, have a unix-friendly path, and hunt down all nested dependencies. The python version issues gave a big messy error, the space issue gave a much more missable error.
I know this is an old issue but I wanted to comment on it in case anyone else has the same issue I had.
My issue was caused by having parentheses in my path.
/users/karlgroves/Dropbox (Personal)/foo/bar/bat/project...
Moving the project to a path without the parens worked for me.
You'll need to wipe out node_modules and reinstall again.
I recently ran into this error as well on node v8.8.1
as #Derek mentioned, I ran npm rebuild dtrace-provider and that resolved the problem.
tl;dr; dtrace-provider utilized node-gyp which required python version >= 2.5 and NOT 3.5
I had this issue on OSX and found a post that showed using environment variable
V=/Users/your_user/your_project npm i dtrace-provider
This let me know that there was a dependency on node-gyp that was failing to build...Once I knew the issue was with this module was able to focus my attention at troubleshooting node-gyp.
This led to some log output indicating that my python version 3.5 was unsupported and it required version >= 2.5.
Went and downloaded python 2.7.x and checked /usr/bin/python 2.7.x to ensure it was there. Uninstalled the node module that was ultimately requiring this module, then used npm cache clean then reinstalled the module and this time it appeared to pick up the right python version to be able to build.
Hope this helps someone =)
I have tried many suggestions but get the same error again.
Finally, I found the correct way to solve this question.
Go the node.js website and download the latest version of node.js pkg.
After installed, reinstall your software, everything will be ok.
i managed to get this working by running this command
npm install --python=python2.7

Resources