ng build gives an error that
Unable to Find npm install -g #angular/cli#latest in devDependencies.
To start application using npm start, but when I try to build a file it is Giving me an error Message in CMD:
Unable to find "#angular/cli" in devDependencies. Please take the
following steps to avoid issues: "npm install --save-dev
#angular/cli#latest" Versions of #angular/compiler-cli and typescript
could not be determined. The most common reason for this is a broken
npm install. Please make sure your package.json contains both
#angular/compiler-cli and typescript in devDependencies, then delete
node_modules and package-lock.json (if you have one) and run npm
install again.
I follow all the step as it suggest me in Error message, but still it is giving me same message enter image description here
I had the same issue following steps helped me to resolve it,
Update package json
from
"angular-cli": "anything"
to
"#angular/cli": "1.0.4"
Deleted node_modules and installed node modules again with
npm install
Change angular-cli.json for
from
"environments": {
"source": "environments/environment.ts"
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
to
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
It seems that you have a problem with your node_modules. Delete the node_modules and package-lock.json and be sure you have all the dependencies in your package.json. After that run npm install
Another point could be that you don't have installed the #angular/cli module.
Like in the error message said, try to install this package with npm install -g #angular/cli.
Related
I can install this node package
npm install #gamestdio/timer --save
However, when I try to install the types which go along with it
npm install #types/#gamestdio/timer --save
The result is
Invalid package name "#types/": name can only contain URL-friendly characters
You can use yarn
yarn add #types/#gamestdio/timer
or manually add to your package.json:
"dependencies": {
"#types/": "gamestdio/timer",
}
then remove your node_modules folder and run npm install again
I am having trouble grasping why the command "npm update" isn't updating the angular-cli to version 7.3.0, however when I run "npm install" the version of angular-cli is now 7.3.0.
The link below shows the MacOS's terminal output, detailing the version update from angular-cli 6.2.9
angular-cli update process
package.json file screenshots thanks to molamk's feedback
dependencies
devDependencies
npm install and npm update by default handle devDependencies
differently
npm install will install/update devDependencies unless --production flag is added.
npm update will ignore devDependencies unless --dev flag is added
So in your case, you did npm update without the --dev flag resulted ignores the angular-cli version update.
Hope this will help!
I am using ubantu 16 OS and i have installed
Node version v10.13.0 and npm version 6.4.1
I am creating Reactjs project based on create-react-app.
I have created project using command
sudo npm init react-app my-app
This command successfully created my-app, but when i am running project using npm start
command under my-app folder i am getting following error
> my-app#0.1.0 start /home/karan/workspace/1425/my-app
> react-scripts start
There might be a problem with the project dependency tree. It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"babel-jest": "23.6.0"
Don't try to install it manually: your package manager does it automatically. However, a different version of babel-jest was detected higher up in the tree:
/home/karan/workspace/node_modules/babel-jest (version: 22.4.4)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project. That will permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact order:
1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "babel-jest" from dependencies and/or devDependencies in the package.json file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem. If this has not helped, there are a few other things you can try:
5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
6. Check if /home/karan/workspace/node_modules/babel-jest is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls babel-jest in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed babel-jest.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project. That would permanently disable this preflight check in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! my-app#0.1.0 start: `react-scripts start` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the my-app#0.1.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
As this is showing issue related
react-scripts start ,"babel-jest": "23.6.0"
but i am new to js framework(node/npm/react), how this problem will resolve please help?
package.json
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.6.3",
"react-dom": "^16.6.3",
"react-scripts": "2.1.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
Even though you're receiving an ELIFECYCLE error and not an EACCES, maybe it's something related to the fact that you used sudo to run the command. Try to create and run the project again, without sudo.
Follow this guide for more details on how to do it.
I am coming across a very bizarre error when installing packages for my webpack/reactjs application.
I am currently trying to install
npm install copy-webpack-plugin --save dev
The build/start scripts fail and the following error is shown in the terminal:
Unsupported platform for inotify#1.4.1: wanted {"os":"linux","arch":"any"} (current: {"os":"darwin","arch":"x64"})
This means absolutely noting to me and I cannot find any clear explanations online.I do not know why inotify is needed or when/where it has been installed.
Package.json scripts:
"scripts": {
"start": "node server.js",
"build": "cross-env BABEL_ENV=production ./node_modules/.bin/webpack --config webpack.config.production.js",
"lint": "eslint --cache --ignore-path .gitignore --format=node_modules/eslint-formatter-pretty . *.js",
"test": "npm run lint"
},
There is a typo in your command:
npm install copy-webpack-plugin --save dev
Should be:
npm install copy-webpack-plugin --save-dev
(You forgot a dash)
The typo will make npm try to install https://www.npmjs.com/package/dev, which depends on inotify.
Your error message is because inotify only works on Linux and you are on a Mac.
You unintentionally tried to install dev package https://www.npmjs.com/package/dev that is not supported on your OS.
It does add only when I execute: npm install <package_name> --save
In the documentation though: https://docs.npmjs.com/cli/install is written this:
By default, npm install will install all modules listed as dependencies in package.json.
Which is misleading.
npm install without arguments installs all dependencies (and dev dependencies) listed in the package.json file.
npm install --production installs all the dependencies (but no dev dependency)
npm install <package> installs a package and its dependencies.
npm install <package> --save installs a package and its dependencies, and adds it in the package.json file.
Edit: Since npm 5, --save is implied.
No, it's not. I think you are misreading the sentence.
npm install without any package name (as in your quote) will install all dependencies mentioned in the package.json.
Crete package.json file in your application folder.
Exp:- var/www/html/node/rest/package.json
{
"name": "node-api",
"main": "server.js",
"version": "0.0.1",
"dependencies": {
"express": "~4.0.0",
"mongoose": "~3.6.13",
"body-parser": "~1.0.1",
"mysql": "^2.5.4"
}
}
Then run npm install command your application folder
Exp:- var/www/html/node/rest npm install
You could run npm init again to update the dependencies info.