question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`Unexpected character '@'` when using path aliases

See original GitHub issue

What happens and why it is wrong

Just try same way index.ts: import SomeComponent from '@common/SomeComponent'; and got error:

Error: Unexpected character ‘@’ (Note that you need plugins to import files that are not JavaScript) at error (C:\Projects\PACWorld\Branches\PacWorldWeb3-vuejs\PacWorld3\node_modules\rollup\dist\rollup.js:9408:30) at Module.error (C:\Projects\PACWorld\Branches\PacWorldWeb3-vuejs\PacWorld3\node_modules\rollup\dist\rollup.js:13347:9) at tryParse (C:\Projects\PACWorld\Branches\PacWorldWeb3-vuejs\PacWorld3\node_modules\rollup\dist\rollup.js:13262:16) at Module.setSource (C:\Projects\PACWorld\Branches\PacWorldWeb3-vuejs\PacWorld3\node_modules\rollup\dist\rollup.js:13573:33) at Promise.resolve.catch.then.then.then (C:\Projects\PACWorld\Branches\PacWorldWeb3-vuejs\PacWorld3\node_modules\rollup\dist\rollup.js:16398:20)

Environment

Win10, MS Visual Studio 2019

Versions

  • typescript: 3.5.2
  • rollup: 1.17.0
  • rollup-plugin-typescript2: 0.22.1

rollup.config.js

const rolTts = require('ttypescript');
const rolTypescript = require('rollup-plugin-typescript2');
// ...
plugins: [
	rolTypescript({
		tsconfig: './src/tsconfig.json',
		clean: true,
		tsconfigOverride: {
			declaration: false,
			compileOnSave: false,
		},
		typescript: rolTts,
	}),
]

tsconfig.json

	"extends": "../tsproject.json",
	"compilerOptions": {
		"baseUrl": ".",
		"paths": {
			"@common/*": ["./common.blocks/*"]
		}
	}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
viT-1commented, Aug 2, 2019

Initially tsconfig was without “compileOnSave” option, but with adding this option to tsconfig file I have two funny errors:

rpt2: config error TS5023: Unknown compiler option ‘compileOnSave’. rpt2: config error TS5024: Compiler option ‘compileOnSave’ requires a value of type boolean.

Thats why I need to workaround through adding “tsconfigOverride” =(

0reactions
agilgur5commented, May 11, 2022

I’m not sure what was going on in OP’s codebase as no repro was provided and the issue they linked to (#159) was due to an invalid misconfiguration. The config posted here has a similar misconfiguration, compilerOptions is missing within tsconfigOverrides.

I also found the old commit from a repo they later linked (I modified their comment to point to the permalink as well), but didn’t see a Rollup config there, so hard to tell what the issue was here.

It was likely a misconfiguration though, as lots of people have gotten path aliases, ttypescript, and ts-transform-paths working with this plugin; see #201 for one reference (can point to more in downstream TSDX as well). OP also said in their last comment that they eventually used rollup-plugin-import-resolver, which is a plugin for resolving things like path aliases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected character '@' You may need an appropriate ...
You are using the (scss|css) twice in your configuration file. ... var path = require('path'); var _root = path.resolve(__dirname, '.
Read more >
Found unexpected or unknown characters - Elastic
If the YAML file contains paths with spaces or unusual characters, wrap the paths in single quotation marks (see Wrap paths in single...
Read more >
parsing JSON error - Power Platform Community - Microsoft
The error says: Unexpected character encountered while parsing ... Just double check which values you are using the title and alias fields.
Read more >
YAML Ain't Markup Language (YAML™) revision 1.2.2
The character stream may be ill-formed, aliases may be unidentified, unspecified tags may be unresolvable, tags may be unrecognized, the content ...
Read more >
Unexpected Character thrown when trying to perform REST calls
When trying to use REST API, you receive an Unexpected Character error ... Note that there is an additional alias (@) before the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found