ify-loader icon indicating copy to clipboard operation
ify-loader copied to clipboard

read-package-json raises an error when the package name is not valid

Open rubeniskov opened this issue 5 years ago • 0 comments

Some libraries such as @apollo/client/react has no an standard package name so when webpack tries to compile raises an error like this, due read-package-json validation.

Error: Invalid name: "@apollo/client/react"
    at ensureValidName (.../node_modules/read-package-json/node_modules/normalize-package-data/lib/fixer.js:336:15)
    at Object.fixNameField (.../node_modules/read-package-json/node_modules/normalize-package-data/lib/fixer.js:215:5)
    at .../node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js:32:38
    at Array.forEach (<anonymous>)
    at normalize (.../node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js:31:15)
    at final (.../node_modules/read-package-json/read-json.js:424:5)
    at then (.../node_modules/read-package-json/read-json.js:156:5)
    at ReadFileContext.callback (.../node_modules/read-package-json/read-json.js:345:20)
    at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:237:13) undefined

I suggest to change the way package.json is loaded using the default require method which is nodejs standard, it will validate only the format and not follow the npm structure.

rubeniskov avatar Oct 30 '20 16:10 rubeniskov