I\'m trying to import a module as import Something from \"@module\"
, but it returns
Cannot find module \'@config\'
\"@m
"paths"
should be in "compilerOptions"
section, not in root of tsconfig.json
More info on path mapping here
Overview of tsconfig.json
here
I had a similar issue with "moment" I have import like below and it does work.
import * as moment from 'moment';
Note that the import will seem fine while developing by importing moment this way, but you may get an AOT error when doing a prod compile, something like, "can not use reference" or some such like that. To not elaborate over much, this has to do (as I understand it) with some CommonJS modules. Moment is very popular, so it seems to come up quite a bit.
To get around that one (which I ran into a couple of weeks ago), set "moment" to a const:
import * as moment from 'moment':
(later where you declare consts)
const _moment = moment;
And then you use _moment in your code.