Webpack are throwing this error all of a sudden:
TypeError: webpack.validateSchema is not a function
Everything was working fine Friday, not working today. No new commits to master since Friday.
Pruned NPM, that didn't work, deleted NPM folder and re-installed, no dice. Checked out to previous branches which have not been rebased from Master for over a week. Still the same.
Anyone have an idea?
Looks like npm bug, since webpack-dev-server#2.1.0-beta.11 requires webpack#^2.1.0-beta.26 but npm failed to install it.
The easiest way to avoid the issue without updating too much is to change dependency in package.json to
"webpack-dev-server": "2.1.0-beta.10",
Instead of something like
"webpack-dev-server": "^2.1.0-beta.9",
"^" char before version says "compatible with". Removing it sticks to the version exactly.
Don't forget to run npm install or npm update afterwards.
I ran into this problem today at virtually the same time as you, it turns out that webpack was updated again.
Here is what I did to fix it:
First I ran npm install and npm update to see what the result was. I ran both of these commands because npm has a weird way of reporting unmet dependancies, sometimes its wrong and when you re-run the npm update or the npm install, you will realize that the unmet dependencies are no longer an issue.
After I ran these commands I noticed that the only remaining message was a warning:
npm WARN webpack-dev-server#2.1.0-beta.11 requires a peer of webpack#^2.1.0-beta.26 but none was installed.
To get rid of this I changed my package.json file to read "webpack": "2.1.0-beta.26" instead of "webpack": "2.1.0-beta.25" and ran another npm install.
After this I got another error when I tried running npm start which stated that there was a problem with my webpack config file. In my case, I went to the webpack config file for my development environment (because I am not on production yet) and I found the culprit which was an invalid parameter called 'outputPath'.
I commented out that line and now I get everything working fine.
Hope this helps, may just be a hack for now but hopefully it is a step in the right direction.
UPDATE:
Ok, so I was a bit wrong about everything 'working fine'. It turns out that some of my loaders were not working correctly; Bootstrap and some other things were not being loaded in properly, breaking my styles. So, to get it back to where I was before, I deleted my node_modules folder and ran npm install using the following in package.json:
"webpack": "2.1.0-beta.25",
"webpack-dashboard": "^0.1.8",
"webpack-dev-middleware": "^1.6.1",
"webpack-dev-server": "2.1.0-beta.9",
"webpack-md5-hash": "^0.0.5",
"webpack-merge": "^0.15.0",
Hopefully discussions like this one will help us figure out how to move forward properly with the new versions of webpack being released.
I got the same error as well. I locked my version of webpack-dev-server in my package.json file and that prevented the error from occurring. That doesn't fix the root problem of the bug though.
This is the version of webpack-dev-server that I'm using but I'm sure later versions work as well:
"webpack-dev-server": "2.1.0-beta.9",
it worked for me when i delete ^ and use the exact version.
From
"webpack": "2.1.0-beta.25",
"webpack-dev-middleware": "^1.6.1",
"webpack-dev-server": "^2.1.0-beta.9",
"webpack-md5-hash": "^0.0.5",
"webpack-merge": "^0.14.1"
to
"webpack": "2.1.0-beta.25",
"webpack-dev-middleware": "1.6.1",
"webpack-dev-server": "2.1.0-beta.9",
"webpack-md5-hash": "0.0.5",
"webpack-merge": "0.14.1"
It worked for me when i did:
Uninstall following package:
npm uninstall webpack webpack-dev-server --save -dev
Install following Packages:
npm install --save -dev webpack#3.10.0
npm install --save -dev webpack-cli#2.0.10
npm install --save -dev webpack-dev-server#2.9.7
Alright, update here.
Tried what a few of you guys suggested, which unfortunately just got me deeper into a rabbit hole of errors with broken module loaders.
In the end, I updated to "webpack": "^2.1.0-beta.26", and "webpack-dev-server": "^2.1.0-beta.11". After that, found out there were breaking changes, causing the loaders to break - https://github.com/webpack/webpack/releases.
in short, in your webpack config, change loaders: [ ... ], to rules : [ ... ], and on all loader declarations, append "-loader" to the string value as this,
{ test: /node_modules\/i18n-iso-countries\/(de|es|nl|sv)\.js$/, loader: 'null-loader' },
{ test: /\.coffee$/, loader: 'coffee-loader' },
{ test: /\.ts$/, loader: ['awesome-typescript-loader']} etc.
Did it for me. Hope this helps anyone else running into the issue.
I got it working by running this command:
npm install --save-dev webpack-dev-server#beta webpack#beta
As explained in this GitHub issue, you need to update webpack to webpack 2.1.0-beta.26 or later. Since the last v2.1 release is beta.28, you should require webpack#^2.1.0-beta.28.
Note that one of the breaking changes introduced in beta.26 is that you need to specify the full name of loaders, e.g. replace loader: 'babel' with loader: 'babel-loader'.
Got the same issue when we upgraded angular/cli to 1.6.3 and when we test the ng -v we get an error towards webpack.
So we happen to uninstall webpack, do an cache clean and then installed the webpack again globally.
It resolved the issue
I got this problem because I had an older global version of webpack installed that was somehow conflicting with the project-specific webpack.
I first un-installed the global (older) webpack by running:
npm uninstall webpack -g
Then I ran my project-specific webpack. On windows webpack.cmd resides in node_modules.bin\, but if you run webpack via an npm task, npm will search the .bin folder automatically, so no need to specify that path explicitly.
The functioning npm run task in my package.json looks as follows:
"scripts": {
"webpack": "webpack -w --config ./config/dev.js --progress"
}
In any angular application
First do npm install, then do npm update.
Worked for me
Related
I'm new to working with Sanity, and just set up a project. Everything is working fine, however, in Visual Studio Code, I keep getting a parsing error that won't disappear, and I'm wondering how I can fix it.
Parsing error: Cannot find module '#babel/preset-env'
I've tried deleting the node_modules and re-running sanity install, I've also tried using npm install to install #babel/core and #babel/preset-env. Nothing seems to have fixed the problem so far.
Any suggestions? I want to start using Sanity with my team at work, but having this error is really quite annoying (as everything is underlined in red).
I was having a similar issue. For me, the issue was related to the way VS Code deals with a project containing multiple ESLint working directories (common in monorepos).
For example
Project
|--- /web
|--- /studio
In my project root, edit (or create) ./.vscode/settings.json to include my ESLint projects. NB: these settings only apply to your current workspace.
"eslint.workingDirectories": ["./web", "./studio"]
Hope that helps :-)
Method 1:
Create a file called .babelrc in your root directory and add this code
{
"presets": ["next/babel"],
"plugins": []
}
And in .eslintrc replace the existing code with
{
"extends": ["next/babel"]
}
Method 2:
You need to install npm with this command:
npm install --save-dev #babel/core #babel/preset-env
or
npm install --save-dev #babel/core
I hope this will solve your problem.
I cannot figure out how to update a package installed from a git repository.
Say I have a package at git+ssh://git#gitlab.example.com:project/my-package.git and it's already installed.
Now, if I:
push into my-package master branch;
run npm i or npm update;
then nothing gets updated.
I thought the version field (from the dependent package.json of my-package) might raise the problem so I removed it and re-installed the package from scratch. Unfortunately it didn't help, the package is still not being updated.
Any ideas?
Ok, folks. Suprisingly, it doesn't seem possible to get it working out-of-the-box.
But there is a workaround. Thanks to #RobC for pointing me out to some old (yet never resolved) issue: https://github.com/npm/npm/issues/1727
The answer is in the last comment:
https://github.com/npm/npm/issues/1727#issuecomment-354124625
Basically, to update a git package you have to re-install it directly using: npm install package-name.
Example. Say you already have your package installed and added to the dependencies like this:
{
"dependencies": {
"my-package": "git+ssh://git#gitlab.my.com:prj/my-package.git"
}
}
Now, to get it updated whenever you issue npm i all you have to do is to create a postinstall script which would trigger npm i my-package:
{
"dependencies": {
"my-package": "git+ssh://git#gitlab.my.com:prj/my-package.git"
},
"scripts": {
"postinstall": "npm update && npm i my-package"
}
}
Now npm i will be taking more time since it's gonna run install twice. But this is what we have now.
Basically, I have a node project and recently github has flagged a potential security vulnerability in one of my dependencies.
It's with cryptiles being version 3.1.2 and recommends I go to version 4.1.2.
Cryptiles is in my package-lock.json but I don't currently have it installed in my package.json nor is it being used anywhere in my project.
I've never worked just with package-lock.json, I tried to change the version in there, but when I run npm install, it changes it back. Solutions?
Would upgrading Node solve it? One of my npm modules? Should I just dismiss this since it's not being used in my project? Want to make sure i'm being safe though.
Here is the two sections in my package-lock.json with cryptiles, neither that nor hawk are installed in my package.json
},
"cryptiles": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz",
"integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=",
"requires": {
"boom": "5.2.0"
},
And here:
},
"hawk": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz",
"integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==",
"requires": {
"boom": "4.3.1",
"cryptiles": "3.1.2",
"hoek": "4.2.1",
"sntp": "2.1.0"
},
Would appreciate any help and anyone who can help me understand the situation so this doesn't happen again.
npm ls {module name} will allow you to see the dependency tree. Updating the parent dependency usually fixes the transitive dependency (dependency of dependency).
This article can be helpful if you need to force a dependency version.
https://www.npmjs.com/package/npm-force-resolutions
Found moderate severity vulnerabilities
run npm audit fix to fix them, or npm audit for details
Following some suggestions above, I followed the depedencies to see which npm module I installed used it. I upgraded the module and it removed the dependency and issue
I am Japanese web developer and I am not good at English , sorry.
I am using library by npm.
I forked the library and I remade it.
I changed my package.json like this.
"libraryName": "git+https://github.com/MyGitName/libraryName#master",
"npm install" worked properly.
But now I want to import same library in different name.
I want to subtend them by branches.
package.json
"libraryName1": "git+https://github.com/MyGitName/libraryName#master1",
"libraryName2": "git+https://github.com/MyGitName/libraryName#master2",
TypeScript
import library as libraryName1 from "libraryName1";
import library as libraryName2 from "libraryName2";
I want to do something like this.
Anyone know the way to do this?
What I tried.↓
1.yarn install -g
2.yarn add lodash2#npm:lodash#2.x
3.edit package.json like this.
"libraryName1": "git+https://github.com/MyGitName/libraryName#master1",
"libraryName2": "git+https://github.com/MyGitName/libraryName#master2",
4.yarn add libraryName1
↑ error occured.
This is not possible with npm currently. You could use yarn instead of npm to solve this. Otherwise you need to publish your own npm package.
package.json example to install both bootstrap 3 and 4. This only works with yarn.
"dependencies": {
"bootstrap": "^4.1.3",
"bootstrap3": "git://github.com/twbs/bootstrap#3.3.7"
}
Sources:
Install multiple versions of a dependency #5499
Yarn tip: You can alias a package by using...
My situation is this :
I had a working copy of a react-native project that was working well. Had it commited to my git repository.
I decided to upgrade react-native to 0.26.3 and then 0.28 and finally ended up in a big dependency mess with collisions. So decided to go back to previous working version. Reverted the changes. Removed node_modules folder from my working directory.
But now npm install just won't work.
My working dependencies in package.json
"dependencies": {
"immutable": "^3.8.1",
"key-mirror": "^1.0.1",
"react": "^15.0.2",
"react-native": "^0.26.0",
"react-native-router-flux": "^3.26.1",
"react-redux": "^4.4.5",
"redux": "^3.5.2",
"redux-thunk": "^2.1.0",
"strformat": "0.0.7"
},
"devDependencies": {
"babel-core": "^6.10.4",
"babel-jest": "^12.1.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react-native": "^1.9.0",
"babel-register": "^6.9.0",
"chai": "^3.5.0",
"fetch-mock": "^4.5.4",
"jest-cli": "^12.1.1",
"mocha": "^2.5.3",
"mockery": "^1.7.0",
"nock": "^8.0.0",
"redux-mock-store": "^1.1.1",
"sinon": "^1.17.4",
"sinon-chai": "^2.8.0",
"sinon-stub-promise": "^2.0.0"
}
Now I get
npm ERR! peerinvalid The package react#15.1.0 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer react-native#0.26.3 wants react#15.0.2
npm ERR! peerinvalid Peer react-redux#4.4.5 wants react#^0.14.0 || ^15.0.0-0
This just not makes sense to me, as my react dependency is 15.0.2 and react-native 0.26.0 as you can see in package.json.
Note that this is from a previous commit that was working (the whole lot).
I also did a npm ls. Weirdly wrong dependencies are shown in the tree like wrong versions of react-native, react-native-router-flux, react.
link to ls output
For existing projects if you want to install/downgrade to lower version
npm install react-native#x.x.x ex: npm install react-native#0.43.4
This will install the version specified.
Check the installed version with react-native --version
Update 2020
Just run
npm install react-native#0.43.8
Replace 0.43.8 with version you need.
Please update your react dependency in package.json to explicitly be 15.0.2, not ^15.0.2 since the latter resolves to 15.1.0 which causes this issue. It is recommended to leave it that way until you upgrade for the next time and get this error once again (to avoid react changing its version in the meantime and react-native not being ready for it).
Also, with npm3 EPEERINVALID is no longer an error, but warning.
Downgrading React Native requires manual steps. I recommend using https://react-native-community.github.io/upgrade-helper/ and here are my steps
Set your current version as base and select the previous minor version of react-native
Revert all the changes made to files as displayed in the compare view in step 1
Delete node_modules folder, clear watchman, reset metro cache, delete pods, clear ios and android cached files. npx react-native-clean-project is super helpful.
yarn or npm install and reinstall pods for ios
Make sure all your jest tests, detox tests and manually testing both iOS and Android are working as expected.
(if needed) Repeat the steps to downgrade to another lower version
Suggestion: If you're downgrading multiple minor versions then it might be easier to downgrade one version at a time. For example, downgrading from 0.61.x to 0.58.x, would be less work to downgrade to version 0.60.x first, test and make sure everything works in iOS and Android then move on
Try npm prune and then npm i again.
The command npm prune will basically remove all unwanted packages, and npm i will make sure all missing packages are installed.
If you're using react-native you can modify your package.json file with the versions that you need and then delete all your node modules rm -rf node_modules and then reinstall npm install
If you change the version in Package.json and reinstall npm packages it will make build errors. Please refer and downgrade/upgrade to a specific version.
I tried to downgrade from react-native 0.71.1 to 0.70.4 with just npm i react-native#0.70.4 and fix whatever errors came up. In my case I needed this because the package react-native-vision-camera was not yet compatible with react-native 0.71.1.
But I had dozens of errors, which after I while I started to understand are due to the fact that the whole android folder that is being set up from a template when you run the npx react-native init script, has differences and must match the react-native package version. So I guess if you downgrade a minor version in this way, not just a patch, you are just very lucky if it works somehow. I would not do it.
I instead decided to freshly init react-native with the desired version:
Just git commit all your changes and push them to the remote (to be safe), mv your current project folder to a different name.
Run npx react-native init <YourProjectName> --version 0.70.6 to get the desired version, but make sure to use the same ProjectName, otherwise you might have configuration mismatches.
Integrate your own code from the old project folder (if you forget something git will tell you later), merge configuration files, etc.
add packages by running npm install <package-name> <package-2-name> <etc.) and npm install -D (for devDependencies). Don't copy the dependencies / devDependencies over from package.json, as that way you'll probably not get the right package versions that match your versions of react, react-native etc.
finally copy .git folder from your old project folder into the new one, and check the changes, to make sure you did not forget anything. And then you will actually see all the differences in the template I mentioned above. In my case more than 30 files were different between those minor versions.