Reputation: 2933
I have installed webpack (Symfony encore) using npm as follows:
sudo npm install -g @symfony/webpack-encore --save-dev
I ran this from /var/www/project
I was required to install globally due to issues with package managers and shared folders when dealing with Windows host / Linux guest.
I cannot install webpack (node_modules) in the same directory (or under it) as the /var/www/project
So my package.json file looks like this:
{
"name": "test",
"version": "1.0.0",
"description": "This is a test",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"@symfony/webpack-encore": "^0.15.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Alex",
"license": "MIT"
}
I run encore from /var/www/project
using this
/usr/local/bin/encore dev
I get this lovely output in return:
Running webpack ...
TypeError: Cannot read property 'match' of undefined
- index.js:125 parse
[lib]/[webpack-encore]/[yargs-parser]/index.js:125:12
- index.js:761 Function.Parser.detailed
[lib]/[webpack-encore]/[yargs-parser]/index.js:761:10
- yargs.js:938 Object.Yargs.self._parseArgs
[lib]/[webpack-encore]/[yargs]/yargs.js:938:27
- yargs.js:927 Object.get [as argv]
[lib]/[webpack-encore]/[yargs]/yargs.js:927:19
- index.js:725 Object.configureRuntimeEnvironment
[lib]/[@symfony]/webpack-encore/index.js:725:54
- index.js:770 Proxy.parameters
[lib]/[@symfony]/webpack-encore/index.js:770:45
- webpack.config.js:3 Object.<anonymous>
/var/www/project/webpack.config.js:3:8
- module.js:573 Module._compile
module.js:573:30
- module.js:584 Object.Module._extensions..js
module.js:584:10
- module.js:507 Module.load
module.js:507:32
What am I missing?
Upvotes: 81
Views: 109815
Reputation: 44
Try npm cache clean --force
This will clear the npm
cache and may resolve your issue.
Upvotes: 2
Reputation: 2028
Follow the steps below:
npm cache clear --force
(after execution, NPM install is ineffective, and then proceed to step 2)
Delete package-lock.json under the project folder, and then run NPM install (step 3 is ineffective)
rm -rf node_modules
rm package-lock.json
npm cache clear --force
npm install
Upvotes: 0
Reputation: 58
If your having the following error when running: npm install
npm ERR! Cannot read property 'matches' of null
Then do the following delete on Windows: C:\Users/{User-Name}\AppData\Roaming\npm C:\Users/{User-Name}\AppData\Roaming\npm-cache
Then re-run: npm install
Worked for me enjoy. :)
Upvotes: 0
Reputation: 1095
Try rebuilding node-sass inside your project directory
npm rebuild node-sass
Upvotes: 0
Reputation: 185
Simply remove package-lock.json
with this cmd command:
rm -rf package-lock.json
Upvotes: 16
Reputation: 356
Delete package-lock.json file and retry installing by command - npm install.
Upvotes: 2
Reputation: 77
You need to remove package-lock.json
from the root directory of the application. After this, you can update your new package.
Upvotes: 6
Reputation: 17
If you're having trouble with NPM, use YARN. (Especially Windows users)
But you MUST first:
Also, you might want to think of using Laragon to have a standardized development environment instead of having to ensure you have installed WAMP and all sort of goodies by yourself.
I've pulled my hair out for ages trying to figure this out, wondering why sometimes things just weren't working.
I hope this helps someone out there.
Upvotes: 0
Reputation: 47
Try the below:
npm install
in CMD or Terminal inside the project directory.The issue should be fixed.
Upvotes: 3
Reputation: 88
If you are trying to npm install
with a lock file, you might actually be looking for the npm ci
command which installs the version-locked dependencies.
npm-ci documentation: https://docs.npmjs.com/cli/ci.html
Upvotes: 0
Reputation: 4356
I have this same issue since Java 11.
Try to run yarn install ...
instead.
It works for me.
Upvotes: 0
Reputation: 3536
Try to delete package-lock.json and node_modules folder and after that run npm install
or yarn install
Upvotes: 32
Reputation: 5881
An additional reason for this message can be a mismatch between the npm
major version that the package-lock.json
was generated with and the version the npm install
is run on.
If for example the lockfile was generated using npm@5
and later you try to npm install
on npm@6
because of lets say a minor node@8
update you will see this error.
The solution here is like mentioned in the other answers to remove node_modules
and package-lock.json
and npm install
on npm@6
again. Or stay on npm@5
for lockfile and later install.
Upvotes: 12
Reputation: 2005
After adding an argument to the configureRuntimeEnvironment
method it started working for me:
Encore.configureRuntimeEnvironment('dev');
Somehow if you omit the argument(s) the error keeps showing up.
Upvotes: 0
Reputation: 1842
Installing webpack-encore
globally is currently not supported. The error message however is not really explanatory.
There is an issue open to improve this error message: https://github.com/symfony/webpack-encore/issues/36
You should try to install webpack-encore
locally, this is the real issue here.
Upvotes: 0