shelljs / shelljs

:shell: Portable Unix shell commands for Node.js
https://www.npmjs.com/package/shelljs
BSD 3-Clause "New" or "Revised" License
14.19k stars 725 forks source link

Cannot find module './src/common' only in npm version 2 #508

Closed ZeroCho closed 7 years ago

ZeroCho commented 7 years ago

Node version (or tell us if you're using electron or some other framework):

4.1.2 ( npm 2.14.4)

ShellJS version (the most recent version/Github branch you see the bug on):

0.7.3

Operating system:

Google App Engine("Debian GNU/Linux 8 (jessie)")

Description of the bug:

I recently changed npm version from 3 to 2 in order to use google app engine. I could successfully install packages when i was using npm3, but after i changed to npm2, this error happens. I don't use this package directly. It is installed via dependencies of postcss-cssnext.

I think it's related to the way npm installs packages. I heard that npm3 differently installs its packages than npm2.

> caniuse-api@1.5.1 postinstall C:\Users\ZeroCho\WebstormProjects\zerocho-home\node_modules\caniuse-api
> node generator.js

module.js:338
    throw err;
    ^

Error: Cannot find module './src/common'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:286:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (C:\Users\ZeroCho\WebstormProjects\zerocho-home\node_modules\shelljs\shell.js:9:14)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)

and the strange thing is, after failing npm install, I tried to run that command again, then it succeeded. First install always fails and second install succeeds.

EDIT: more console message

Linux 3.16.0-4-amd64
npm ERR! argv "/usr/local/nvm/versions/node/v4.1.2/bin/node" "/usr/local/nvm/versions/node/v4.1.2/bin/npm" "i" "--production"
npm ERR! node v4.1.2
npm ERR! npm  v2.14.4
npm ERR! code ELIFECYCLE

npm ERR! caniuse-api@1.5.1 postinstall: `node generator.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the caniuse-api@1.5.1 postinstall script 'node generator.js'.
npm ERR! This is most likely a problem with the caniuse-api package,
npm ERR! not with npm itself.
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node generator.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls caniuse-api
npm ERR! There is likely additional logging output above.
nfischer commented 7 years ago

@ZeroCho which version of shelljs is this? I've never seen anything like this on Ubuntu.

Does the command npm install shelljs fail?

ZeroCho commented 7 years ago

0.7.3 and this only happens when installing caniuse-api. after failure, I typed npm list shelljs and console shows that shelljs 0.7.3 is extraneous. Installing just this package succeeds.

zerocho-home@2.0.0-beta8
│ /home/zerohch0/src/zerocho-1353/zerocho
│ git+https://github.com/zerocho/zerocho.git
│ https://github.com/zerocho/zerocho#readme
├─┬ eslint@3.3.1
│ │ An AST-based pattern checker for JavaScript.
│ │ git+https://github.com/eslint/eslint.git
│ │ http://eslint.org
│ └── shelljs@0.6.1 
│     Portable Unix shell commands for Node.js
│     git://github.com/shelljs/shelljs.git
│     http://github.com/shelljs/shelljs
└── shelljs@0.7.3  extraneous
    Portable Unix shell commands for Node.js
    git://github.com/shelljs/shelljs.git
    http://github.com/shelljs/shelljs
    https://registry.npmjs.org/shelljs/-/shelljs-0.7.3.tgz
nfischer commented 7 years ago

@ZeroCho I just tried this and I'm unable to produce the error. Here are some commands I can run from a fresh npm package that still succeed (deleting node_modules/ makes each command like a fresh install). This is all on Ubuntu.

$ npm -v
2.14.4
$ rm -rf node_modules
$ npm install shelljs
$ rm -rf node_modules
$ npm install caniuse-api
$ rm -rf node_modules
$ npm install postcss-cssnext

Could you please show me your package.json?

ZeroCho commented 7 years ago

sorry for he late reply.

  "dependencies": {
    "axios": "^0.13.1",
    "babel-cli": "^6.10.1",
    "babel-core": "^6.9.1",
    "babel-loader": "^6.2.4",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-plugin-transform-react-constant-elements": "^6.9.1",
    "babel-plugin-transform-react-inline-elements": "^6.8.0",
    "babel-plugin-transform-react-remove-prop-types": "^0.2.9",
    "babel-plugin-transform-runtime": "^6.12.0",
    "babel-polyfill": "^6.9.1",
    "babel-preset-es2015": "^6.9.0",
    "babel-preset-react": "^6.5.0",
    "babel-preset-stage-0": "^6.5.0",
    "babel-runtime": "^6.11.6",
    "better-npm-run": "0.0.10",
    "body-parser": "^1.15.1",
    "classnames": "^2.2.5",
    "compression": "^1.6.2",
    "connect-mongo": "^1.3.2",
    "cookie-parser": "^1.4.3",
    "cors": "^2.7.1",
    "css-loader": "^0.23.1",
    "eventsource-polyfill": "^0.9.6",
    "express": "^4.14.0",
    "express-session": "^1.13.0",
    "extract-text-webpack-plugin": "^1.0.1",
    "fb": "^1.1.1",
    "file-loader": "^0.9.0",
    "font-awesome": "^4.6.3",
    "gravatar": "^1.5.2",
    "helmet": "^2.1.2",
    "inline-environment-variables-webpack-plugin": "1.1.0",
    "json-loader": "^0.5.4",
    "method-override": "^2.3.6",
    "moment": "^2.14.1",
    "mongoose": "^4.5.9",
    "morgan": "^1.7.0",
    "newrelic": "^1.28.3",
    "nodemailer": "^2.5.0",
    "nodemon": "^1.10.0",
    "passport": "^0.3.2",
    "passport-facebook": "^2.1.1",
    "passport-google-oauth": "^1.0.0",
    "passport-kakao": "0.0.3",
    "passport-local": "^1.0.0",
    "passport-twitter": "^1.0.4",
    "postcss-cssnext": "^2.7.0",
    "postcss-import": "^8.1.2",
    "postcss-loader": "^0.10.0",
    "postcss-reporter": "^1.4.1",
    "react": "^15.3.0",
    "react-addons-shallow-compare": "^15.3.0",
    "react-dom": "^15.3.0",
    "react-fb-like": "^0.2.4",
    "react-filepicker": "^0.9.0",
    "react-ga": "^2.1.1",
    "react-helmet": "^3.1.0",
    "react-prism": "^3.2.1",
    "react-redux": "^4.4.5",
    "react-router": "^2.6.1",
    "react-router-redux": "^4.0.5",
    "react-rte-image": "^0.5.1",
    "react-share": "^1.9.0",
    "redux": "^3.5.2",
    "rimraf": "^2.5.4",
    "rss": "^1.2.1",
    "socket.io": "^1.4.6",
    "socket.io-client": "^1.4.6",
    "static-loader": "^0.1.8",
    "style-loader": "^0.13.1",
    "url-loader": "^0.5.7",
    "webpack": "^1.13.1",
    "webpack-dev-middleware": "^1.6.1",
    "webpack-hot-middleware": "^2.12.2"
  },
  "devDependencies": {
    "eslint": "^3.3.1",
    "eslint-config-airbnb": "^10.0.1",
    "eslint-plugin-import": "^1.13.0",
    "eslint-plugin-react": "^6.1.1",
    "eslint-plugin-jsx-a11y": "^2.1.0",
    "babel-preset-react-hmre": "^1.1.1",
    "react-perf-tool": "^0.1.5",
    "react-addons-perf": "^15.3.0",
    "redux-devtools": "^3.3.1",
    "redux-devtools-dock-monitor": "^1.1.1",
    "redux-devtools-log-monitor": "^1.0.11",
    "why-did-you-update": "0.0.8",
    "webpack-visualizer-plugin": "^0.1.5"
  }
nfischer commented 7 years ago

@ZeroCho I just tried out your package.json and I had no issues installing. Also, you don't have ShellJS listed in your project, so this sounds more like it's an issue with one of your other packages.

I'm going to close this. Feel free to ping this thread again if you still believe this to be a ShellJS issue and you have more info for us to track this down.