LINQ: Can not find module "."
I am using the following libraries:
Angular 2.0.1
Angular-CLI 1.0.0-Beta.16 (using webpack)
linq-es2015 2.4.1
TypeScript 2.0.3
With npm I did:
npm install linq-es2015
npm install @types/linq-es2015
I want to import your linq library in MyComponent.ts:
import * as Enumerable from 'linq-es2015';
In the angularcli configuration file I modify the scripts array:
"scripts": ["../node_modules/linq-es2015/dist/linq.js"],
Then I run my application and in the browser console I get that error:
Can not find module "." in your linq.js. line 16
The first thing I realized is that in my project under node_modules/@types/ there exist no linq-es2015 folder at all.
But I do not think thats the problem why I get that error during runtime.
I have still added a screenshot from chrome browser:
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 25 (11 by maintainers)
“module”: “commonjs” have to be set in source code of linq-es2015 before build.
If you want quick fix, you can change linq.js (and the same way other js files) in lib folder:
(function (factory) { if (typeof module === 'object' && typeof module.exports === 'object') { var v = factory(exports); if (v !== undefined) module.exports = v; } else if (typeof define === 'function' && define.amd) { define(["require", "exports", "./generators", "./utilities", "./iterators"], factory); } })(function (exports) {
(remove require from function parameters)