jest-schematic
jest-schematic copied to clipboard
Invalid JSON character: "\n" at 59:34.
Describe the bug
I followed the read me and when running the add
schematics it printed Invalid JSON character: "\n" at 59:34.
To Reproduce Steps to reproduce the behavior:
- install the package globally
- run the add schematic in an angular project
Expected behavior The schematic runs
Desktop (please complete the following information):
- OS: windows
- Node version: 8.12
- NPM or Yarn version 6.4.1
- App type Angular CLI
- Angular version 7.0.2
Thank you for reporting. This schematic changes two json files, package.json and tsconfig.spec.json. Are you able to determine which file the error is coming from based on the line number (59)? Changes to tsconfig.spec.json are new so thats the likely culprit.
This is my tsconfig.spec.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false,
"outDir": "../out-tsc/spec",
"module": "commonjs",
"types": ["jasmine", "node"]
},
"files": ["test.ts", "polyfills.ts"],
"include": ["**/*.spec.ts", "**/*.d.ts", "**/*.mock.ts"]
}
The tsconfig which it extends
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"noEmit": true,
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": ["../node_modules/@types"],
"lib": ["es2017", "dom"],
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true
}
}
So, even combined, there is no line 59 😕
Was there every any solution to this?
I'm getting a similar issue Invalid JSON character: "-" at 76:5.
no other output
I think we ended up using https://github.com/just-jeb/angular-builders/tree/master/packages/jest instead :/
in my case it turned out to be a packge.json npm script that contained the following string \\nsomefolder
, the characters '\n' verbatim were in the file causing the error.
adding the file name that is the problem to the error string would have helped.
Also not having a "test" script in the packge.json seems to cause a similar error
This might be resolved in the latest PR https://github.com/briebug/jest-schematic/pull/37/files#diff-99dba52ba3c99a2cb3d95d1ada2821f8R278 where we looses the "strictness" of the JSON parsing. Can anyone test the current schematic to see if it's fixed?
This should be fixed in the latest 3.0.0 release with https://github.com/briebug/jest-schematic/pull/37/files#diff-99dba52ba3c99a2cb3d95d1ada2821f8R278. Please reopen if not.
I just used the latest version of this project and I had the same issue:
ng add @briebug/jest-schematic
Installing packages for tooling via npm.
Installed packages for tooling via npm.
Invalid JSON character: "\n" at 155:35.
It seems to happen in my package.json
but at said line and curser position there is only a whitespace.
For those still having problems, what operation systems are you using?
For those still having problems, what operation systems are you using?
I'm so sorry. I realized that I am in the @jest-schematic repo. My apologies. I'm using cypress-schematic
. I'll delete my comment and post in the correct repo. My apologies @schuchard
For those still having problems, what operation systems are you using?
I am using Windows 10
But my issues I think where, that \t
and \n
made some issues. I guess it has to do something with my line endings. which are set to CRLF
and will be only be changed, when I commit to LF
.
ng add @briebug/jest-schematic
ℹ Using package manager: npm
✔ Found compatible package version: @briebug/[email protected].
✔ Package information loaded.
The package @briebug/[email protected] will be installed and executed.
Would you like to proceed? Yes
✔ Package successfully installed.
Invalid JSON character: "\"" at 81:11.
Angular 13 MacOS 14.1
ng add @briebug/jest-schematic i Using package manager: npm √ Found compatible package version: @briebug/[email protected]. √ Package information loaded.
The package @briebug/[email protected] will be installed and executed. Would you like to proceed? Yes √ Packages successfully installed. Invalid JSON character: "\t" at 53:24.
Angular 16 Windows 10