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

Error: Cannot find module 'immutable' on existing project deploying on server #2588

Closed
jkbaseer opened this issue Jan 6, 2019 · 8 comments
Closed
Assignees

Comments

@jkbaseer
Copy link

jkbaseer commented Jan 6, 2019

Informations

  • Node.js version: v10.15.0
  • NPM version: 6.4.1
  • Strapi version: 3.0.0-alpha.18
  • Database: PostegreSQL
  • Operating system: Ubuntu 16.04
  • (Optional) Link to your Project:

What is the current behavior?
`root@ed-api-v1:~/ed-api# strapi start
internal/modules/cjs/loader.js:583
throw err;
^

Error: Cannot find module 'strapi-generate'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (/root/ed-api/plugins/content-type-builder/services/ContentTypeBuilder.js:6:19)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
^C
`

Steps to reproduce the problem
If you have hosted this on ubuntu 16.04 with a code that is pulled from your bitbucket (A) , it may not work. but it works when we create a new project.

What is the expected behavior?

The app should strart running in the localserver:1337 as everytime it does.

Suggested solutions
While researching, people are suggesting this is due to the new node version node-inspector/node-inspector#1044

Few people ask to delete node_modules directory and package.json. it doesn't work

  1. but if i see the problem is with lodash module, so i deleted the folder, removed from package folder. And tried strapi start ( am not sure whether it is stupid, then i got node module not found, so i installed fresh of Lodash and again the same issue.

And i got this npm audit as well, in case it helps
image

@ntloi95
Copy link

ntloi95 commented Jan 7, 2019

In your generated app you can run:

npm i it install all node modules in your project, admin and plugins
npm run setup --plugins it build admin and all plugins

@jkbaseer
Copy link
Author

jkbaseer commented Jan 7, 2019

Thanks Man @ntloi95

Yes, i went to do it again.

` root@ed-api-v1:~/projectname/ed-api# npm i
npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
npm WARN checkPermissions Missing write access to /root/projectname/ed-api/node_modules/strapi
npm WARN bookshelf@0.12.1 requires a peer of knex@>=0.6.10 <0.15.0 but none is installed. You must install peer dependencies yourself.
npm WARN gatsby-source-filesystem@1.5.39 requires a peer of gatsby@^1.9.250 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-airbnb@13.0.0 requires a peer of eslint@^3.9.1 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-airbnb@13.0.0 requires a peer of eslint-plugin-jsx-a11y@^2.2.3 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-airbnb@13.0.0 requires a peer of eslint-plugin-react@^6.6.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-airbnb-base@10.0.1 requires a peer of eslint@^3.9.1 but none is installed. You must install peer dependencies yourself.

npm ERR! path /root/projectname/ed-api/node_modules/strapi
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access '/root/projectname/ed-api/node_modules/strapi'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-01-07T10_45_33_952Z-debug.log
`

`root@ed-api-v1:~/projectname/ed-api# npm run setup --plugins

projectname@0.1.0 setup /root/projectname/ed-api
cd admin && npm run setup

strapi-admin@3.0.0-alpha.17 presetup /root/projectname/ed-api/admin
node ./scripts/preSetup.js

🕓 The setup process can take few minutes.

🔸 Administration Panel
📦 Installing packages...

Packaged installed successfully

strapi-admin@3.0.0-alpha.17 setup /root/projectname/ed-api/admin
node ./scripts/setup.js

🏗 Building the admin...
internal/modules/cjs/loader.js:583
throw err;
Error: Cannot find module '/root/projectname/ed-api/node_modules/strapi'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (/root/ethisdigital/ed-api/admin/node_modules/strapi-helper-plugin/lib/internals/scripts/loadAdminConfigurations.js:13:18)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
npm ERR! code ELIFECYCLE
`
same as last time.

@derrickmehaffy
Copy link
Member

@jkbaseer did you install the strapi package globally?

If no, you can't use the strapi command (as your system isn't aware of the location)

There are two places the strapi package is "kept":

  1. In your global node_modules folder to be used as an executable IE strapi start
  2. In your project's node_modules/package.json for use by strapi

The reason for the split is, it is possible you may not need the global CLI based tool while running in production if you are using npm start server.js

Please run npm i -g strapi@alpha to use strapi start globally (or any of the CLI based commands like generate)

@derrickmehaffy
Copy link
Member

I'm marking this issue as closed for now, please update if this didn't fix the issue and we can re-open it.

@jkbaseer
Copy link
Author

jkbaseer commented Jan 7, 2019

Hey Guys, I would request to open up this issue because i tried running commands like

  1. installing strapi alpha on the global using npm i -g strapi@alpha

  2. root@ed-api-v1:~/ed/ed-api# ls
    README.md admin api config favicon.ico node_modules package.json plugins public server.js

root@ed-api-v1:~/ed/ed-api# strapi start
internal/modules/cjs/loader.js:583
throw err;
^

Error: Cannot find module 'immutable'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (/root/ed/ed-api/plugins/content-type-builder/services/ContentTypeBuilder.js:7:31)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
`

it doesn't seem to help.

@derrickmehaffy
Copy link
Member

@Aurelsicoko @lauriejim maybe you can assist here. I think he is using Node Version Manager (NVM) which I believe is causing the issue.

@Aurelsicoko
Copy link
Member

Did you try to delete the package-lock.json file?

@thkdog
Copy link

thkdog commented Jan 15, 2019

Did you try to delete the package-lock.json file?

I have solved the problem, you can fixed it in 2 ways:
1.

npm install --unsafe-perm
npm i
npm run postinstall

Check this related issue: npm WARN cannot run in wd node-gyp

Which causing the problem is the node_modules in plugins are not installed.
When using npm i in dockerfile, the postinstall script won't be excuted, as below:

npm WARN lifecycle website-service@0.1.0~postinstall: cannot run in wd website-service@0.1.0 node node_modules/strapi/lib/utils/post-install.js (wd=/usr/src/app)

So you have to execute it manually or using --unsafe-perm options.

@strapi strapi locked as resolved and limited conversation to collaborators Jan 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants