npm - install explained - angularjs

I'm trying to grasp how npm install works.
Shouldn't this have installed all the dependencies in package.json ?
I wen't to the docs npm install
npm install (in package directory, no arguments):
Install the dependencies in the local node_modules folder.
1)
What i understood is when invoking npm install This package.json (/protractor/package.json) is not the place where npm will look for dependencies in the folder i am currently in.
In /node_modules there a are a bunch of packages each with it's own package.json
Why are they not getting installed ?
2)
When first cloning the app , i wen't into the root folder invoked npm install
And node models were created , and all the dependecies in ~/angular-phonecat/package.json were installed.
Why doesn't it work the same way from inside the protractor folder ?
Does it have something to do with the warning above ?

You are in an installed package. When you install protractor it automatically installs all it's dependencies because protractor is an NPM package. If you delete the "node_modules" folder in there and type npm install, it will reinstall everything. Note: this is not the purpose of npm.
NPM is used for when you have your own project and you store it on a repository, you can add all the dependencies so when a user downloads the repository they can just type npm install to get the dependencies from npm.

Related

Hello: this problem appear when i try to deploy to vercel, i need help to solve

I try this steps to try solve.enter image description here
Clear the npm cache:
Run npm cache clean --force in your terminal.
Then, run npm install again.
Reinstall npm packages:
Delete the node_modules directory and package-lock.json file.
Run npm install again to reinstall all of the packages specified in your package.json file.
Use npm dedupe:
Run npm dedupe in your terminal.
This command will resolve and remove duplicate packages in your project's dependencies.
Upgrade or downgrade package versions:
Check the latest version of each package that is causing the conflict.
If possible, upgrade or downgrade the packages to versions that are compatible with each other and with React.

Change yarn to npm when using npx install react-create-app

I already uninstalled yarn but when I run node package execute (npx) create-react-app, yarn lock is still there but i can run it with node package manager (npm) start. How can I get I back to package-lock json or npm version when i create-react-app using npx create-react-app.
I wanna use npm for react and react-native projects.
Just delete the yarn.lock and run npm install and it will generate a package-lock.json.
package-lock.json is automatically generated for any operations where npm modifies either the node_modules tree, or package.json. https://docs.npmjs.com/cli/v7/configuring-npm/package-lock-json

Why React npm start return error for webpack-dev-server 3.11.1?

I have the following error with npm start in my React application:
The react-scripts package provided by Create React App requires a dependency:
"webpack-dev-server": "3.11.1"
Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack-dev-server was detected higher up in the tree:
C:\Users\Username\node_modules\webpack-dev-server (version: 3.11.0)
Usually I fixed this type of issue by running the following code: npm install react-scripts#latest.
But now it seems like that React is not updated yet to the latest webpack-dev-server
Now the question is how to fix that. By the way, I use npx create-react-app for my project, Thanks!
I have write following commands in react project
Open project in command prompt
npm uninstall -g webpack-dev-server
remove web-dev-server folder from node_modules(C:/Users/UserName/Node_Modules)
npm i -g webpack-dev-server#3.11.1
remove package-lock.json and write npm install
after it your react project may be start by npm start
First, remove the node_modules folder and yarn-lock or package-lock.json file.
And, then add this line in your .env file:
SKIP_PREFLIGHT_CHECK=true
Now you can do npm start or yarn start after re-installing the packages. It should work.
Explanation:
For some reasons, you have two versions of webpack-dev-server installed in your project's node_modules. By setting SKIP_PREFLIGHT_CHECK=true in .env file, we are telling npm to ignore such version issues.
Check if node_modules and package-lock.json are present in your home folder, instead of your project folder. If yes, delete those two folders and then go for npm start.

How to fix ReactJs Sass Not Compiling and error showing in vs code?

I am trying to use sass in my reactjs project and I tried
npm install node-sass
after install and import it with scss extension but not working it,
I used W3Schools Tutorial but still not working
error showing this
./src/myStyle.scss (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-5-1!./node_modules/postcss-loader/src??postcss!./node_modules/resolve-url-loader??ref--6-oneOf-5-3!./node_modules/sass-loader/dist/cjs.js??ref--6-oneOf-5-4!./src/myStyle.scss)
To import Sass files, you first need to install node-sass.
Run `npm install node-sass` or `yarn add node-sass` inside your workspace.
The error is:
Run npm install node-sass or yarn add node-sass inside your workspace.
This means that the node-sass was not found inside the node_modules folder of the reactjs project.
This problem can be fixed by explicitly installing node-sass inside the project folder (using --save option along with npm install inside the project folder)
cd react-js-project-folder
npm install --save node-sass
npm install --save node-sass must be run in the root of the react-js project, I.E., at the same folder where package.json is located.

How Yarn manages package.json and bower.json files, when both are present in my project's root folder?

In my project's root folder,both bower.json and package.json are present.
When using npm previosly,i do both npm and bower install seperately.Now i switched to Yarn.My question is, what happens when i do a yarn install?
Will all the dependencies from package.json and bower.json will get
installed?
please help.
Yarn decided to drop Bower support for now. Yarn won't look at your bower.json. You will need to do bower install aside from yarn.
https://bower.io/blog/2016/using-bower-with-yarn/
A newer article https://bower.io/blog/2017/how-to-migrate-away-from-bower/ explains on how to move your dependencies from bower to Yarn
The tool bower-away mentioned in the article will convert your bower.json contents to a package.json format (may need to run a few times to resolve all the dependencies) and this can then be installed with Yarn/npm/...
From what I understand, Yarn still doesn't look at bower.json
If you're like me and have npm packages installed in a different directory to bower packages, you can try npm install --prefix or yarn install --modules-folder. For Yarn, the folder used will be a replacement of node_modules, but make sure to have a read of https://github.com/yarnpkg/yarn/issues/1684

Resources