patch-package icon indicating copy to clipboard operation
patch-package copied to clipboard

** Error ** Unknown token: { line: 4, col: 2, type: 'INVALID', value: undefined } 4:2 in lockfile

Open admin8756 opened this issue 1 year ago • 5 comments

image

I was trying to modify the elementui. Remind me of this error

admin8756 avatar Jul 11 '22 05:07 admin8756

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

landsman avatar Aug 22 '22 16:08 landsman

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

admin8756 avatar Aug 25 '22 13:08 admin8756

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

erick-martins avatar Sep 06 '22 20:09 erick-martins

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.

admin8756 avatar Sep 07 '22 05:09 admin8756