codesandbox-client icon indicating copy to clipboard operation
codesandbox-client copied to clipboard

Error running build:dev for @codesandbox/common: Cannot find module './_copyObject'

Open shiftyp opened this issue 7 years ago • 10 comments

🐛 bug report

Description of the problem

In following the instructions to set up my project locally, I get the following error when running yarn start, in particular it fails running the build:dev script for the @codesandbox/common package.

yarn run v1.17.3
$ yarn build:deps && yarn start:fast
$ lerna run build:dev --scope codesandbox-api --scope @codesandbox/notifications --scope @codesandbox/executors && lerna run build:dev --scope @codesandbox/common && lerna run build:dev --scope vscode-textmate --scope codesandbox-browserfs --scope node-services && lerna run build:dev --scope sse-hooks && lerna run build --scope codesandbox-deps
lerna info version 2.5.1
lerna info versioning independent
lerna info scope [ 'codesandbox-api',
lerna info scope   '@codesandbox/notifications',
lerna info scope   '@codesandbox/executors' ]

> [email protected] build:dev /Users/ryan/code/codesandbox-client/packages/codesandbox-api
> tsc && rollup -c


> @codesandbox/[email protected] build:dev /Users/ryan/code/codesandbox-client/packages/notifications
> yarn build

$ rimraf lib && tsc

> @codesandbox/[email protected] build:dev /Users/ryan/code/codesandbox-client/packages/executors
> yarn build

$ tsdx build
✓ Creating entry file 11.5 secs
lerna success run Ran npm script 'build:dev' in packages:
lerna success - codesandbox-api
lerna success - @codesandbox/executors
lerna success - @codesandbox/notifications
lerna info version 2.5.1
lerna info versioning independent
lerna info scope @codesandbox/common
lerna ERR! build:dev Errored while running script in '@codesandbox/common'
lerna ERR! execute callback with error
lerna ERR! Error: Command failed: npm run build:dev
lerna ERR! warning package.json: No license field
lerna ERR! warning package.json: No license field
lerna ERR! warning package.json: No license field
lerna ERR! warning package.json: No license field
lerna ERR! warning package.json: No license field
lerna ERR! { Error: Cannot find module './_copyObject'
lerna ERR!     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
lerna ERR!     at Function.Module._load (internal/modules/cjs/loader.js:508:25)
lerna ERR!     at Module.require (internal/modules/cjs/loader.js:637:17)
lerna ERR!     at require (internal/modules/cjs/helpers.js:22:18)
lerna ERR!     at Object.<anonymous> (/Users/ryan/code/codesandbox-client/node_modules/@babel/preset-env/node_modules/lodash/assignIn.js:1:80)
lerna ERR!     at Module._compile (internal/modules/cjs/loader.js:701:30)
lerna ERR!     at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
lerna ERR!     at Module.load (internal/modules/cjs/loader.js:600:32)
lerna ERR!     at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
lerna ERR!     at Function.Module._load (internal/modules/cjs/loader.js:531:3) code: 'MODULE_NOT_FOUND' }
lerna ERR! error Command failed with exit code 1.
lerna ERR! error Command failed with exit code 1.
lerna ERR! npm ERR! code ELIFECYCLE
lerna ERR! npm ERR! errno 1
lerna ERR! npm ERR! @codesandbox/[email protected] build:dev: `yarn build`
lerna ERR! npm ERR! Exit status 1
lerna ERR! npm ERR!
lerna ERR! npm ERR! Failed at the @codesandbox/[email protected] build:dev script.
lerna ERR! npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
lerna ERR!
lerna ERR! npm ERR! A complete log of this run can be found in:
lerna ERR! npm ERR!     /Users/ryan/.npm/_logs/2019-07-26T12_34_53_675Z-debug.log
lerna ERR!
lerna ERR! > @codesandbox/[email protected] build:dev /Users/ryan/code/codesandbox-client/packages/common
lerna ERR! > yarn build
lerna ERR!
lerna ERR! $ yarn clean && yarn tsc && yarn babel src --out-dir lib && yarn cpx "src/**/*.{css,svg,png,jpg}" lib
lerna ERR! $ rimraf lib && yarn rimraf node_modules/@types/react-native
lerna ERR! $ /Users/ryan/code/codesandbox-client/node_modules/.bin/rimraf node_modules/@types/react-native
lerna ERR! $ /Users/ryan/code/codesandbox-client/node_modules/.bin/tsc
lerna ERR! $ /Users/ryan/code/codesandbox-client/node_modules/.bin/babel src --out-dir lib
lerna ERR! info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lerna ERR! info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lerna ERR!
lerna ERR!     at Promise.all.then.arr (/Users/ryan/code/codesandbox-client/node_modules/lerna/node_modules/execa/index.js:236:11)
(node:60378) UnhandledPromiseRejectionWarning: Error: Command failed: npm run build:dev
warning package.json: No license field
warning package.json: No license field
warning package.json: No license field
warning package.json: No license field
warning package.json: No license field
{ Error: Cannot find module './_copyObject'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/Users/ryan/code/codesandbox-client/node_modules/@babel/preset-env/node_modules/lodash/assignIn.js:1:80)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3) code: 'MODULE_NOT_FOUND' }
error Command failed with exit code 1.
error Command failed with exit code 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @codesandbox/[email protected] build:dev: `yarn build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @codesandbox/[email protected] build:dev 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!     /Users/ryan/.npm/_logs/2019-07-26T12_34_53_675Z-debug.log

> @codesandbox/[email protected] build:dev /Users/ryan/code/codesandbox-client/packages/common
> yarn build

$ yarn clean && yarn tsc && yarn babel src --out-dir lib && yarn cpx "src/**/*.{css,svg,png,jpg}" lib
$ rimraf lib && yarn rimraf node_modules/@types/react-native
$ /Users/ryan/code/codesandbox-client/node_modules/.bin/rimraf node_modules/@types/react-native
$ /Users/ryan/code/codesandbox-client/node_modules/.bin/tsc
$ /Users/ryan/code/codesandbox-client/node_modules/.bin/babel src --out-dir lib
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

    at Promise.all.then.arr (/Users/ryan/code/codesandbox-client/node_modules/lerna/node_modules/execa/index.js:236:11)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:60378) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
(node:60378) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I've tried wiping out node_modules and re-installing, downgrading lerna (unsure if lerna is involved) and eliminating mismatched lodash dependencies. All I know about the cause is that the required file in node_modules/@babel/preset-env/node_modules/lodash does appear to be missing, so that's what I've been working off of.

How has this issue affected you? What are you trying to accomplish?

I'm trying to run codesandbox-client to make contributions

Link to sandbox: link (optional)

Your Environment

Software Name/Version
Сodesandbox N/A
Browser N/A
Operating System macOS Mojave 10.14.3
Node 10.15.3
NPM 6.4.1
Yarn 1.17.3
codesandbox-client 0.1.0

shiftyp avatar Jul 26 '19 12:07 shiftyp

Hmm, that is indeed very weird. Where did you run yarn? In the root of the repo?

CompuIves avatar Jul 26 '19 15:07 CompuIves

Yes, from the root of the repo. For me (and in the error log) it's /Users/ryan/code/codesandbox-client.

shiftyp avatar Jul 26 '19 15:07 shiftyp

In fact I just tried from a fresh clone: yarn install && yarn start and experienced the same failure.

shiftyp avatar Jul 26 '19 15:07 shiftyp

Hey @shiftyp ,

What OS / versions (yarn, node) are you on?

lbogdan avatar Jul 26 '19 16:07 lbogdan

Hey @shiftyp ,

What OS / versions (yarn, node) are you on?

I've listed OS, Yarn, and Node versions at the bottom of the report.

shiftyp avatar Jul 26 '19 16:07 shiftyp

It turns out this was an issue with my environment. Fixed by yarn cache clean lodash. Something must have been corrupted in there and it was pulling from that with each install. Thanks for your assistance!

shiftyp avatar Jul 26 '19 16:07 shiftyp

Cannot find module '@codesandbox/common/lib/version'

I'm getting this on clean environment. building it via vercel.

app-root : packages/app command: yarn -> yarn build dist: www


yarn run v1.22.10
--
18:15:59.557 | $ cross-env NODE_ENV=production NODE_OPTIONS="--max-old-space-size=4096"   node scripts/build.js
18:16:01.048 | internal/modules/cjs/loader.js:638
18:16:01.048 | throw err;
18:16:01.049 | ^
18:16:01.049 | Error: Cannot find module '@codesandbox/common/lib/version'
18:16:01.049 | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
18:16:01.049 | at Function.Module._load (internal/modules/cjs/loader.js:562:25)
18:16:01.049 | at Module.require (internal/modules/cjs/loader.js:692:17)
18:16:01.049 | at require (internal/modules/cjs/helpers.js:25:18)
18:16:01.049 | at Object.<anonymous> (/vercel/workpath0/packages/app/config/webpack.prod.js:13:17)
18:16:01.049 | at Module._compile (internal/modules/cjs/loader.js:778:30)
18:16:01.049 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
18:16:01.049 | at Module.load (internal/modules/cjs/loader.js:653:32)
18:16:01.049 | at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
18:16:01.049 | at Function.Module._load (internal/modules/cjs/loader.js:585:3)
18:16:01.049 | at Module.require (internal/modules/cjs/loader.js:692:17)
18:16:01.049 | at require (internal/modules/cjs/helpers.js:25:18)
18:16:01.049 | at Object.<anonymous> (/vercel/workpath0/packages/app/scripts/build.js:10:16)
18:16:01.049 | at Module._compile (internal/modules/cjs/loader.js:778:30)
18:16:01.049 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
18:16:01.050 | at Module.load (internal/modules/cjs/loader.js:653:32)
18:16:01.069 | error Command failed with exit code 1.
18:16:01.069 | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
18:16:01.078 | Error: Command "yarn run build" exited with 1
18:16:05.591 | Done with "package.json"


softmarshmallow avatar Feb 20 '21 09:02 softmarshmallow

Cannot find module '@codesandbox/common/lib/version'

Getting the same error, did you solve this?

pkl avatar Mar 26 '23 15:03 pkl

Sorry, I missed the this step: yarn build:steps

Works now.

pkl avatar Mar 26 '23 15:03 pkl

Delete your node_module caches for lodash otherwise every attempt to install reads the version in there: rm -rf /Users/xxx/Library/Caches/Yarn/v6/npm-lodash-4.17.21-679591c564c3bffaae8454cf0b3df370c3d6911c-integrity Remember to change "xxx" to your own mac username.

Then run: yarn add lodash

PhpGuyZim avatar Nov 28 '23 12:11 PhpGuyZim