Skip to content

Error: Cannot find module 'package.json' #1898

Closed

Description

@ThomasKnobloch
  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
    Mac OS X 10.11.5 (El Capitan)
  2. Versions. Please run ng --version. If there's nothing outputted, please run
    in a Terminal: node --version and paste the result here:
    angular-cli: 1.0.0-beta.11-webpack.8
    node: 6.5.0
    os: darwin x64
  3. Repro steps. Was this an app that wasn't created using the CLI? What change did you
    do on your code? etc.
    clone from repository
    npm install --save-dev angular-cli@webpack
    ng version
  4. The log given by the failure. Normally this include a stack trace and some
    more information.
Cannot find module 'package.json'
Error: Cannot find module 'package.json'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at AddonDiscovery.discoverAtPath (/Users/thomasknobloch/workspace/OXEWbm2/wbm/node_modules/angular-cli/lib/models/addon-discovery.js:205:20)
    at AddonDiscovery.<anonymous> (/Users/thomasknobloch/workspace/OXEWbm2/wbm/node_modules/angular-cli/lib/models/addon-discovery.js:114:26)
    at Array.map (native)
    at AddonDiscovery.discoverFromDependencies (/Users/thomasknobloch/workspace/OXEWbm2/wbm/node_modules/angular-cli/lib/models/addon-discovery.js:109:68)
    at AddonDiscovery.discoverProjectAddons (/Users/thomasknobloch/workspace/OXEWbm2/wbm/node_modules/angular-cli/lib/models/addon-discovery.js:48:29)
    at Project.discoverAddons (/Users/thomasknobloch/workspace/OXEWbm2/wbm/node_modules/angular-cli/lib/models/project.js:353:40)
  1. Mention any other details that might be useful.
    ng version works fine outside of my project (using the global installation of angular-cli).

Activity

  1. ThomasKnobloch commented on Aug 31, 2016

    @ThomasKnobloch
    Author

    The problem seems to be in the module ember-cli, the package child_process in the devDependencies of my package.json cannot be resolved.
    There is no more issue when I delete this module in the package.json file of my project.

  2. filipesilva commented on Sep 21, 2016

    @filipesilva
    Contributor

    We had the problem a while ago, but it's fixed in the latest versions.

  3. CoreyCole commented on Oct 16, 2016

    @CoreyCole

    It's happening to me currently on:
    angular-cli: 1.0.0-beta.16
    node: v6.8.1
    npm: 3.10.8

    I've tried wiping node modules and reinstalling the cli after a fresh install of node and npm. Still no luck

  4. filipesilva commented on Oct 17, 2016

    @filipesilva
    Contributor

    @CoreyCole what happened to you was probably fixed by #2178, available in beta.17.

  5. aFluttr commented on Nov 3, 2016

    @aFluttr

    I'm having this same problem on beta 18.

    Cannot find module 'package.json'
    Error: Cannot find module 'package.json'
        at Function.Module._resolveFilename (module.js:469:15)
        at Function.Module._load (module.js:417:25)
        at Module.require (module.js:497:17)
        at require (internal/module.js:20:19)
        at AddonDiscovery.discoverAtPath (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/addon-discovery.js:205:20)
        at AddonDiscovery.<anonymous> (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/addon-discovery.js:114:26)
        at Array.map (native)
        at AddonDiscovery.discoverFromDependencies (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/addon-discovery.js:109:68)
        at AddonDiscovery.discoverProjectAddons (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/addon-discovery.js:48:29)
        at Project.discoverAddons (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/project.js:353:40)
        at Project.initializeAddons (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/project.js:372:8)
        at Project.eachAddonCommand (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/project.js:425:10)
        at module.exports (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/cli/lookup-command.js:33:13)
        at CLI.<anonymous> (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/cli/cli.js:34:26)
        at tryCatch (/Users/ewbutterfield/vs/pct-service/node_modules/rsvp/dist/rsvp.js:538:12)
        at invokeCallback (/Users/ewbutterfield/vs/pct-service/node_modules/rsvp/dist/rsvp.js:553:13)
        at publish (/Users/ewbutterfield/vs/pct-service/node_modules/rsvp/dist/rsvp.js:521:7)
        at flush (/Users/ewbutterfield/vs/pct-service/node_modules/rsvp/dist/rsvp.js:2373:5)
        at _combinedTickCallback (internal/process/next_tick.js:67:7)
        at process._tickCallback (internal/process/next_tick.js:98:9)
    

    angular-cli: 1.0.0-beta.18
    node: v6.9.1
    npm: 3.10.8

  6. filipesilva commented on Nov 4, 2016

    @filipesilva
    Contributor

    This doesn't seem to happen to everyone, and I can't repro. Will leave it open for community help.

  7. AmitMY commented on Nov 4, 2016

    @AmitMY
    Contributor

    Try
    'Npm install --save http'
    It will add "http" on version 0.0.0
    This reliably reproduces the problem
    Tried 3 times, and that is the error.

    I can send a video if you want.

  8. added
    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
    and removed on Nov 4, 2016
  9. filipesilva commented on Nov 4, 2016

    @filipesilva
    Contributor

    @AmitMY got it, thank you!

    kamik@T460p MINGW64 /D/sandbox/master-proj (master)
    $ ng version
    angular-cli: local (v1.0.0-beta.19, branch: fix-broken-e2e-tests)
    node: 6.5.0
    os: win32 x64
    
    kamik@T460p MINGW64 /D/sandbox/master-proj (master)
    $ npm install http --save
    master-proj@0.0.0 D:\sandbox\master-proj
    +-- UNMET PEER DEPENDENCY @types/request@0.0.30
    `-- http@0.0.0
    
    npm WARN optional Skipping failed optional dependency /angular-cli/chokidar/fsevents:
    npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.15
    npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
    npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.15
    npm WARN angularfire2@2.0.0-beta.5 requires a peer of @types/request@0.0.30 but none was installed.
    
    kamik@T460p MINGW64 /D/sandbox/master-proj (master)
    $ ng version
    Cannot find module 'package.json'
    Error: Cannot find module 'package.json'
        at Function.Module._resolveFilename (module.js:455:15)
        at Function.Module._load (module.js:403:25)
        at Function.Module._load (D:\work\angular-cli\lib\bootstrap-local.js:64:22)
        at Module.require (module.js:483:17)
        at require (internal/module.js:20:19)
        at AddonDiscovery.discoverAtPath (D:\work\angular-cli\node_modules\angular-cli\lib\models\addon-discovery.js:205:20)
        at AddonDiscovery.<anonymous> (D:\work\angular-cli\node_modules\angular-cli\lib\models\addon-discovery.js:114:26)
        at Array.map (native)
        at AddonDiscovery.discoverFromDependencies (D:\work\angular-cli\node_modules\angular-cli\lib\models\addon-discovery.js:109:68)
        at AddonDiscovery.discoverProjectAddons (D:\work\angular-cli\node_modules\angular-cli\lib\models\addon-discovery.js:48:29)
        at Project.discoverAddons (D:\work\angular-cli\node_modules\angular-cli\lib\models\project.js:353:40)
        at Project.initializeAddons (D:\work\angular-cli\node_modules\angular-cli\lib\models\project.js:372:8)
        at Project.eachAddonCommand (D:\work\angular-cli\node_modules\angular-cli\lib\models\project.js:425:10)
        at module.exports (D:\work\angular-cli\node_modules\angular-cli\lib\cli\lookup-command.js:33:13)
        at CLI.<anonymous> (D:\work\angular-cli\node_modules\angular-cli\lib\cli\cli.js:34:26)
        at tryCatch (D:\work\angular-cli\node_modules\rsvp\dist\rsvp.js:538:12)
        at invokeCallback (D:\work\angular-cli\node_modules\rsvp\dist\rsvp.js:553:13)
        at publish (D:\work\angular-cli\node_modules\rsvp\dist\rsvp.js:521:7)
        at flush (D:\work\angular-cli\node_modules\rsvp\dist\rsvp.js:2373:5)
        at _combinedTickCallback (internal/process/next_tick.js:67:7)
        at process._tickCallback (internal/process/next_tick.js:98:9)
    
  10. 2 remaining items

  11. gglee89 commented on Nov 18, 2016

    @gglee89

    Was this issue solved? :(

    I'm getting the same issue on:

    $ node --version
    v5.1.0
    $ npm -v
    4.0.2
    $ npm show angular-cli version
    1.0.0-beta.20-4
    

    This is my console output:

    $ ng version
    Cannot find module 'package.json'
    Error: Cannot find module 'package.json'
        at Function.Module._resolveFilename (module.js:338:15)
        at Function.Module._load (module.js:289:25)
        at Module.require (module.js:366:17)
        at require (module.js:385:17)
        at AddonDiscovery.discoverAtPath (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/models/addon-discovery.js:205:20)
        at AddonDiscovery.<anonymous> (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/models/addon-discovery.js:114:26)
        at Array.map (native)
        at AddonDiscovery.discoverFromDependencies (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/models/addon-discovery.js:109:68)
        at AddonDiscovery.discoverProjectAddons (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/models/addon-discovery.js:48:29)
        at Project.discoverAddons (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/models/project.js:353:40)
        at Project.initializeAddons (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/models/project.js:372:8)
        at Project.eachAddonCommand (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/models/project.js:425:10)
        at module.exports (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/cli/lookup-command.js:33:13)
        at CLI.<anonymous> (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/angular-cli/lib/cli/cli.js:34:26)
        at tryCatch (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/rsvp/dist/rsvp.js:538:12)
        at invokeCallback (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/rsvp/dist/rsvp.js:553:13)
        at publish (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/rsvp/dist/rsvp.js:521:7)
        at flush (/Users/giwoogustavolee/Documents/proof-gis-map/node_modules/rsvp/dist/rsvp.js:2373:5)
        at doNTCallback0 (node.js:430:9)
        at process._tickCallback (node.js:359:13)
    
  12. MarkySparky commented on Nov 29, 2016

    @MarkySparky

    I had the same issue. I removed the http package from my dev dependencies and it all started to work.

  13. beeman commented on Dec 20, 2016

    @beeman
    Contributor

    This happened to me when I made a copy of a project and ran ng serve in the copy. My solution was to nuke node_modules and run npm install.

    I can not reproduce this with a new version of the app though.

  14. WeslleyDeSouza commented on Dec 21, 2016

    @WeslleyDeSouza

    i had the same problem with FS from nodejs
    so i had to remove fs package from my dev dependencies and it all started to work again.
    "fs": "0.0.1-security",

  15. Caspain commented on Dec 31, 2016

    @Caspain

    After much reading and analysis, the crypto package cause ember-cli to panic. Just remove it npm uninstall crypto --save

  16. Caspain commented on Jan 7, 2017

    @Caspain

    There seems to be a correlation with streaming associated packages

  17. rikkouri commented on Jan 10, 2017

    @rikkouri

    Hi @filipesilva ,

    I'm quite new to this world of nodejs/angular etc. but hopefully this helps diagnose a fix...

    I found that running strace highlighted a lot of stat syscalls failing towards the end of its execution. It seems that ng is looking for a directory called node_modules/package.json/ which certainly didn't exist in my project. However I did notice that package-json does exist.

    Adding a symlink between the two seem to fix the issue for me. Could this be a simple typo in a recent release?

    Does this help?

    ln -s node_modules/package-json/ node_modules/package.json
    

    strace output for reference:

    $ strace ng serve
    
    ...
    open("/home/rikkouri/WebstormProjects/issue-1898/node_modules/package.json/package.json", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    stat("/home/rikkouri/WebstormProjects/issue-1898/node_modules/package.json/index.js", 0x7fffc0f829b0) = -1 ENOENT (No such file or directory)
    stat("/home/rikkouri/WebstormProjects/issue-1898/node_modules/package.json/index.json", 0x7fffc0f829b0) = -1 ENOENT (No such file or directory)
    stat("/home/rikkouri/WebstormProjects/issue-1898/node_modules/package.json/index.node", 0x7fffc0f829b0) = -1 ENOENT (No such file or directory)
    ...
    write(9, "\33[31mCannot find module 'package"..., 44Cannot find module 'package.json'
    ) = 44
    write(9, "Error: Cannot find module 'packa"..., 2041Error: Cannot find module 'package.json'
        at Function.Module._resolveFilename (module.js:469:15)
        at Function.Module._load (module.js:417:25)
        at Module.require (module.js:497:17)
        at require (internal/module.js:20:19)
        at AddonDiscovery.discoverAtPath (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/models/addon-discovery.js:205:20)
        at AddonDiscovery.<anonymous> (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/models/addon-discovery.js:114:26)
        at Array.map (native)
        at AddonDiscovery.discoverFromDependencies (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/models/addon-discovery.js:109:68)
        at AddonDiscovery.discoverProjectAddons (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/models/addon-discovery.js:48:29)
        at Project.discoverAddons (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/models/project.js:296:40)
        at Project.initializeAddons (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/models/project.js:315:8)
        at Project.eachAddonCommand (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/models/project.js:368:10)
        at module.exports (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/cli/lookup-command.js:33:13)
        at CLI.<anonymous> (/home/rikkouri/WebstormProjects/issue-1898/node_modules/angular-cli/ember-cli/lib/cli/cli.js:43:26)
        at tryCatch (/home/rikkouri/WebstormProjects/issue-1898/node_modules/rsvp/dist/rsvp.js:538:12)
        at invokeCallback (/home/rikkouri/WebstormProjects/issue-1898/node_modules/rsvp/dist/rsvp.js:553:13)
        at publish (/home/rikkouri/WebstormProjects/issue-1898/node_modules/rsvp/dist/rsvp.js:521:7)
        at flush (/home/rikkouri/WebstormProjects/issue-1898/node_modules/rsvp/dist/rsvp.js:2373:5)
        at _combinedTickCallback (internal/process/next_tick.js:67:7)
        at process._tickCallback (internal/process/next_tick.js:98:9)
    ) = 2041
    ...
    
  18. filipesilva commented on Jan 10, 2017

    @filipesilva
    Contributor

    Fixed by #3695

  19. RanaAbdullah2017 commented on Dec 18, 2017

    @RanaAbdullah2017

    [ERROR] Error with .\node_modules\ionic-angular\package.json file: FILE_NOT_FOUND
    [ERROR] Error with .\node_modules@ionic\app-scripts\package.json file: FILE_NOT_FOUND
    I have an above Error when I write this command
    ionic start Myapp tabs
    Can u help me to solve this problem.

  20. beeman commented on Dec 19, 2017

    @beeman
    Contributor

    @RanaAbdullah2017 this is the Angular CLI issue thread, please look for the Ionic support channels when you have problems running Ionic.

  21. gabrielfrischer commented on Jan 10, 2018

    @gabrielfrischer

    I like turtles

  22. saidevops014 commented on Apr 4, 2018

    @saidevops014

    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    Error: Cannot find module '/usr/local/share/.pm2/package.json'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at getPublicUrl (/usr/local/share/applications/cms-admin-ui/config/paths.js:26:19)
    at Object. (/usr/local/share/applications/cms-admin-ui/config/paths.js:54:14)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)

    when i start the application through PM2 am facing this issue please give me the solution for this ..

  23. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  24. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenthelp wantedLabel noting an issue which the team is looking for contribution from the community to fixtype: bug/fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions