Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid JSON character: "\n" at 59:34. #4

Open
eloiqs opened this issue Nov 14, 2018 · 13 comments
Open

Invalid JSON character: "\n" at 59:34. #4

eloiqs opened this issue Nov 14, 2018 · 13 comments

Comments

@eloiqs
Copy link

eloiqs commented Nov 14, 2018

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:

  1. install the package globally
  2. 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
@schuchard
Copy link
Collaborator

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.

@eloiqs
Copy link
Author

eloiqs commented Nov 15, 2018

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 😕

@acharlop
Copy link

Was there every any solution to this?
I'm getting a similar issue Invalid JSON character: "-" at 76:5. no other output

@eloiqs
Copy link
Author

eloiqs commented Jul 30, 2019

I think we ended up using https://github.com/just-jeb/angular-builders/tree/master/packages/jest instead :/

@menaheme
Copy link

menaheme commented Mar 17, 2020

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

@schuchard
Copy link
Collaborator

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?

@schuchard
Copy link
Collaborator

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.

@markusmo
Copy link

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.

@schuchard
Copy link
Collaborator

For those still having problems, what operation systems are you using?

@schuchard schuchard reopened this Feb 4, 2021
@chrisleyva
Copy link

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

@markusmo
Copy link

markusmo commented Feb 8, 2021

For those still having problems, what operation systems are you using?

I am using Windows 10
image

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.

@btd1337
Copy link

btd1337 commented Nov 1, 2023

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

@a-boertien
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants