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

Module not found: Error: Can't resolve '.' #1568

Closed
Muhammad-Soban opened this issue Oct 6, 2018 · 13 comments
Closed

Module not found: Error: Can't resolve '.' #1568

Muhammad-Soban opened this issue Oct 6, 2018 · 13 comments

Comments

@Muhammad-Soban
Copy link

Muhammad-Soban commented Oct 6, 2018

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior
it is working fine if build it using ng serve and ng build --prod. But I am facing issues when I build it for server side rendering with angular universal. I am using following commands to build

npm run build:ssr

ERROR in ./dist/server/main.js
Module not found: Error: Can't resolve '.' in 'C:\Users\me\Desktop\example\dist\server'
@ ./dist/server/main.js 96:17-29
@ ./server.ts

npm run serve:ssr

example@0.0.0 serve:ssr C:\Users\me\Desktop\example
node dist/server

C:\Users\me\Desktop\example\dist\server.js:54955
module.exports = webpack_require(!(function webpackMissingModule() { var e = new Error("Cannot find module '.'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
^

Error: Cannot find module '.'
at webpackMissingModule (C:\Users\me\Desktop\example\dist\server.js:54955:82)
at Object.. (C:\Users\me\Desktop\example\dist\server.js:54955:158)
at webpack_require (C:\Users\me\Desktop\example\dist\server.js:54879:30)
at Object../node_modules/@swimlane/ngx-datatable/release/utils/tree.js (C:\Users\me\Desktop\example\dist\server.js:62913:10)
at webpack_require (C:\Users\me\Desktop\example\dist\server.js:54879:30)
at Object../node_modules/@swimlane/ngx-datatable/release/utils/index.js (C:\Users\me\Desktop\example\dist\server.js:62194:10)
at webpack_require (C:\Users\me\Desktop\example\dist\server.js:54879:30)
at Object../node_modules/@swimlane/ngx-datatable/release/components/header/header-cell.component.js (C:\Users\me\Desktop\example\dist\server.js:59818:15)
at webpack_require (C:\Users\me\Desktop\example\dist\server.js:54879:30)
at Object../node_modules/@swimlane/ngx-datatable/release/components/header/header-cell.component.ngfactory.js (C:\Users\me\Desktop\example\dist\server.js:60109:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! example@0.0.0 serve:ssr: node dist/server
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the example@0.0.0 serve:ssr script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\me\AppData\Roaming\npm-cache_logs\2018-10-06T07_02_52_121Z-debug.log

Expected behavior
Create ssr build without errors.

Reproduction of the problem
I have created a test project to reproduce the issue. Following is the github link.
https://github.com/Muhammad-Soban/ngx-datatable-ssr-issue.git

Please tell us about your environment:
Operating system: Windows 10
IDE: Webstorm
Package manager: npm
package.json:

{
  "name": "example",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
    "serve:ssr": "node dist/server",
    "build:client-and-server-bundles": "ng build --prod && ng run example:server",
    "webpack:server": "webpack --config webpack.server.config.js --progress --colors"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.1.0",
    "@angular/common": "^6.1.0",
    "@angular/compiler": "^6.1.0",
    "@angular/core": "^6.1.0",
    "@angular/forms": "^6.1.0",
    "@angular/http": "^6.1.0",
    "@angular/platform-browser": "^6.1.0",
    "@angular/platform-browser-dynamic": "^6.1.0",
    "@angular/platform-server": "^6.1.9",
    "@angular/router": "^6.1.0",
    "@nguniversal/express-engine": "^6.1.0",
    "@nguniversal/module-map-ngfactory-loader": "^6.1.0",
    "@swimlane/ngx-datatable": "^13.1.0",
    "core-js": "^2.5.4",
    "rxjs": "~6.2.0",
    "ts-loader": "^5.2.1",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.8.0",
    "@angular/cli": "~6.2.4",
    "@angular/compiler-cli": "^6.1.0",
    "@angular/language-service": "^6.1.0",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.3.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~2.9.2",
    "webpack-cli": "^3.1.2"
  }
}
  • Table version:
    "@swimlane/ngx-datatable": "^13.1.0"

  • Angular version:
    Angular 6.1.0

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

  • Language: [all | TypeScript X.X | ES6/7 | ES5]
@Farqual
Copy link

Farqual commented Oct 17, 2018

I've got exactly the same issue here in my project, will keep you updated if I find some solution on this.

@pwalat
Copy link

pwalat commented Nov 9, 2018

Ran into a similar issue when trying to convert my recently migrated Angular 7 app to universal.
Any updates ?

@JSMike
Copy link

JSMike commented Nov 16, 2018

typically this is a tsconfig issue. try adding baseUrl: './'

This was mistaken, ignore.

@Farqual
Copy link

Farqual commented Nov 17, 2018

@JSMike Doesn't seems to change anything, tried to change baseUrl in my project but this issue is still there..

I found a temporary solution to fix this (at least this is working with my project), just start npm run build:client-and-server-bundles then, edit your main.js file and delete this : module.exports=require(".")

Then you can run npm run webpack:server.

@adriwicked
Copy link

I have the same problem trying to implement SSR on a 6.1 angular proyect. I'll try to start from the universal-starter project and add all the features one by one..

@ericel
Copy link

ericel commented Dec 4, 2018

This issue is related to the utils/tree.js file. It imports '.' . I don't know why.
var _1 = require(".");

If you delete this line, then the app should build on universal.

@JSMike
Copy link

JSMike commented Dec 10, 2018

Looks like it's an issue with tree.ts it's importing ValueGetter and getterForProp from the current directory's index.ts which also has export * from './tree'; in it, this is creating a circular dependency which during webpack compilation is causing the unknown import. Typically you don't want to import from an index.ts file that also exports the current source file.

@ericel Deleting the line shouldn't really "fix" the error unless you're not actually using the tree code in your project, you'll get a runtime error.

The fix is to update the src/util/tree.ts file to import ValueGetter and getterForProp directly from ./column-prop-getters.

@marjan-georgiev is this something you can fix real quick? at my current job I can't submit a PR without a bunch of paperwork.

FYI, I searched the project, this is the only file that imports from '.' where the current file is in the index.ts.

@Muhammad-Soban
Copy link
Author

Just downgrade the version of ngx-datatable from "@swimlane/ngx-datatable": "^13.1.0" to "@swimlane/ngx-datatable": "13.0.0". It works.

@jedmarcnocum
Copy link

Any update on this?

@JSMike
Copy link

JSMike commented Jan 25, 2019

@jedmarcnocum I have the fix outlined in my post, due to the company I work for I can't submit the PR right now, trying to get permission. Lots of annoying legal/paperwork stuff. Feel free to implement the change and push a PR if you can.

langfors added a commit to expovation/ngx-datatable that referenced this issue Feb 11, 2019
@langfors langfors mentioned this issue Feb 11, 2019
9 tasks
marjan-georgiev pushed a commit that referenced this issue May 6, 2019
* fix for #1568

* getting datatable SSR compatible

* internal release to support fork
@marjan-georgiev
Copy link
Member

Merged #1646

@steveacalabro
Copy link

@marjan-georgiev Is there a plan to do a release for this?

@marjan-georgiev
Copy link
Member

Released in 15.0.0

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

9 participants