patch-package
patch-package copied to clipboard
** Error ** Unknown token: { line: 4, col: 2, type: 'INVALID', value: undefined } 4:2 in lockfile
I was trying to modify the elementui. Remind me of this error
I have a smillar issue as well:
SyntaxError: Unknown token: { line: 3, col: 2, type: 'INVALID', value: undefined } 3:2 in lockfile
% yarn --version
3.2.0
I have a smillar issue as well:
SyntaxError: Unknown token: { line: 3, col: 2, type: 'INVALID', value: undefined } 3:2 in lockfile
% yarn --version 3.2.0
Our questions seem to be the same, but the author has not updated them for two years
We have the same issue with yarn 2. It's so frustrating that we had to create an work around script to deal with it
Here it is if it would help someone:
#!/usr/bin/env bash
set -e
root="${PWD}"
# Package name and current version
package_name="$1"
version=$(yarn why "${package_name}" | grep -o "${package_name}@npm:[^\[]*" | cut -d ":" -f2)
# Create temporary folder
rm -rf "${root}/tmp"
mkdir "${root}/tmp"
cd "${root}/tmp"
# Creates an empty npm project, install package and copy changes
npm init -y
npm i "${package_name}@${version}"
cp -a "${root}/node_modules/${package_name}/." "./node_modules/${package_name}/"
# Creates the patch, moves it to main project and clean up
npx patch-package "${package_name}"
cp -a ./patches/. "${root}/patches/"
rm -rf "${root}/tmp"
Then call it like this: scripts/yarn-patch-package package-name
We have the same issue with yarn 2. It's so frustrating that we had to create an work around script to deal with it
Here it is if it would help someone:
#!/usr/bin/env bash set -e root="${PWD}" # Package name and current version package_name="$1" version=$(yarn why "${package_name}" | grep -o "${package_name}@npm:[^\[]*" | cut -d ":" -f2) # Create temporary folder rm -rf "${root}/tmp" mkdir "${root}/tmp" cd "${root}/tmp" # Creates an empty npm project, install package and copy changes npm init -y npm i "${package_name}@${version}" cp -a "${root}/node_modules/${package_name}/." "./node_modules/${package_name}/" # Creates the patch, moves it to main project and clean up npx patch-package "${package_name}" cp -a ./patches/. "${root}/patches/" rm -rf "${root}/tmp"
Then call it like this:
scripts/yarn-patch-package package-name
This library has not been updated for a long time. There should be some conflicts with some new features. But I don't have time to deal with it. Your method doesn't look particularly elegant. But it can solve the problem.