yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.43k stars 2.72k forks source link

Yarn removes devDependencies packages while installing new ones #6004

Open 3dos opened 6 years ago

3dos commented 6 years ago

bug

Yarn removes packages from node_modules when adding new ones

I use standardjs as a linter in my IDE (Atom) and it requires the standard package installed in devDependencies. When adding new dependencies, the standard package is removed from the node_modules and I have to install it again each time.

I tried to set my NODE_ENV to development writing

NODE_ENV=development

in /etc/environment an restarted my computer with no success.

Having this issue on a MacBook Pro (High Sierra) with Yarn 1.7.0, Node 10.4.1

rally25rs commented 6 years ago

This doesn't happen under normal operation:

~/Projects/yarn-test2 πŸ’   cat package.json
{
    "name": "yarn-test2",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "dependencies": {},
    "devDependencies": {
        "standard": "^11.0.1"
    }
}

~/Projects/yarn-test2 πŸ’   yarn add left-pad
yarn add v1.7.0
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] πŸ”—  Linking dependencies...
[4/4] πŸ“ƒ  Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ left-pad@1.3.0
info All dependencies
└─ left-pad@1.3.0
✨  Done in 0.99s.

~/Projects/yarn-test2 πŸ’   cat package.json
{
    "name": "yarn-test2",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "dependencies": {
        "left-pad": "^1.3.0"
    },
    "devDependencies": {
        "standard": "^11.0.1"
    }
}

~/Projects/yarn-test2 πŸ’   ls node_modules/standard
AUTHORS.md    LICENSE       RULES.md      bin           eslintrc.json node_modules  package.json
CHANGELOG.md  README.md     SECURITY.md   docs          index.js      options.js

yarn must be picking up the --production or NODE_ENV=production flag from somewhere.

Maybe try running yarn config list and yarn run env and see if "prod" is in the output somewhere?

3dos commented 6 years ago

Thank you for your help @rally25rs . In fact I just tested from the terminal and it seems to run fine as I added packages without the previous issue.

I forgot to mention I was previously using the atom term3 package which adds a terminal into the IDE while having the issue. This may causing this issue.

However, here are the results from the 2 commandes you advised me to run. No prod or production found on these.

$ yarn config list
yarn config v1.7.0
info yarn config
{ 'version-tag-prefix':
   'v',
  'version-git-tag':
   true,
  'version-commit-hooks':
   true,
  'version-git-sign':
   false,
  'version-git-message':
   'v%s',
  'init-version':
   '1.0.0',
  'init-license':
   'MIT',
  'save-prefix':
   '^',
  'bin-links':
   true,
  'ignore-scripts':
   false,
  'ignore-optional':
   false,
  registry:
   'https://registry.yarnpkg.com',
  'strict-ssl':
   true,
  'user-agent':
   'yarn/1.7.0 npm/? node/v10.4.1 darwin x64',
  lastUpdateCheck:
   1529326291949 }
info npm config
{ python:
   '/usr/bin/python' }
✨  Done in 0.07s.
$ yarn run env
yarn run v1.7.0
{
  "NODE": "/usr/local/bin/node",
  "INIT_CWD": "/Users/dos/Workspace/Miysis/Mobitec/mobitec-vidactic",
  "PREFIX": "/usr/local",
  "NPM_CONFIG_PYTHON": "/usr/bin/python",
  "TERM_PROGRAM": "Apple_Terminal",
  "TERM": "xterm-256color",
  "SHELL": "/bin/bash",
  "TMPDIR": "/var/folders/6f/r4ktxllj59g_7qcz2kr3qdy40000gn/T/",
  "Apple_PubSub_Socket_Render": "/private/tmp/com.apple.launchd.VJabC4WKDL/Render",
  "TERM_PROGRAM_VERSION": "404",
  "TERM_SESSION_ID": "C2A9086A-18AA-435C-84EA-C3ABB664C2F2",
  "USER": "dos",
  "SSH_AUTH_SOCK": "/private/tmp/com.apple.launchd.lorSJZBdm7/Listeners",
  "PATH": "/Users/dos/Workspace/Miysis/Mobitec/mobitec-vidactic/node_modules/.bin:/Users/dos/.config/yarn/link/node_modules/.bin:/Users/dos/Workspace/Miysis/Mobitec/mobitec-vidactic/node_modules/.bin:/Users/dos/.config/yarn/link/node_modules/.bin:/usr/local/libexec/lib/node_modules/npm/bin/node-gyp-bin:/usr/local/lib/node_modules/npm/bin/node-gyp-bin:/usr/local/bin/node_modules/npm/bin/node-gyp-bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
  "_": "/usr/local/bin/yarn",
  "PWD": "/Users/dos/Workspace/Miysis/Mobitec/mobitec-vidactic",
  "LANG": "fr_BE.UTF-8",
  "XPC_FLAGS": "0x0",
  "XPC_SERVICE_NAME": "0",
  "HOME": "/Users/dos",
  "SHLVL": "1",
  "LOGNAME": "dos",
  "__CF_USER_TEXT_ENCODING": "0x1F5:0x0:0x62",
  "npm_lifecycle_event": "env",
  "npm_node_execpath": "/usr/local/bin/node",
  "npm_execpath": "/usr/local/Cellar/yarn/1.7.0/libexec/bin/yarn.js",
  "npm_config_argv": "{\"remain\":[],\"cooked\":[\"run\",\"env\"],\"original\":[\"run\",\"env\"]}",
  "npm_package_description": "- [Updating to New Releases](#updating-to-new-releases) - [Sending Feedback](#sending-feedback) - [Folder Structure](#folder-structure) - [Available Scripts](#available-scripts) - [npm start](#npm-start) - [npm test](#npm-test) - [npm run build](#npm-run-build) - [npm run eject](#npm-run-eject) - [Supported Browsers](#supported-browsers) - [Supported Language Features and Polyfills](#supported-language-features-and-polyfills) - [Syntax Highlighting in the Editor](#syntax-highlighting-in-the-editor) - [Displaying Lint Output in the Editor](#displaying-lint-output-in-the-editor) - [Debugging in the Editor](#debugging-in-the-editor) - [Formatting Code Automatically](#formatting-code-automatically) - [Changing the Page `<title>`](#changing-the-page-title) - [Installing a Dependency](#installing-a-dependency) - [Importing a Component](#importing-a-component) - [Code Splitting](#code-splitting) - [Adding a Stylesheet](#adding-a-stylesheet) - [Post-Processing CSS](#post-processing-css) - [Adding a CSS Preprocessor (Sass, Less etc.)](#adding-a-css-preprocessor-sass-less-etc) - [Adding Images, Fonts, and Files](#adding-images-fonts-and-files) - [Using the `public` Folder](#using-the-public-folder) - [Changing the HTML](#changing-the-html) - [Adding Assets Outside of the Module System](#adding-assets-outside-of-the-module-system) - [When to Use the `public` Folder](#when-to-use-the-public-folder) - [Using Global Variables](#using-global-variables) - [Adding Bootstrap](#adding-bootstrap) - [Using a Custom Theme](#using-a-custom-theme) - [Adding Flow](#adding-flow) - [Adding a Router](#adding-a-router) - [Adding Custom Environment Variables](#adding-custom-environment-variables) - [Referencing Environment Variables in the HTML](#referencing-environment-variables-in-the-html) - [Adding Temporary Environment Variables In Your Shell](#adding-temporary-environment-variables-in-your-shell) - [Adding Development Environment Variables In `.env`](#adding-development-environment-variables-in-env) - [Can I Use Decorators?](#can-i-use-decorators) - [Fetching Data with AJAX Requests](#fetching-data-with-ajax-requests) - [Integrating with an API Backend](#integrating-with-an-api-backend) - [Node](#node) - [Ruby on Rails](#ruby-on-rails) - [Proxying API Requests in Development](#proxying-api-requests-in-development) - [\"Invalid Host Header\" Errors After Configuring Proxy](#invalid-host-header-errors-after-configuring-proxy) - [Configuring the Proxy Manually](#configuring-the-proxy-manually) - [Configuring a WebSocket Proxy](#configuring-a-websocket-proxy) - [Using HTTPS in Development](#using-https-in-development) - [Generating Dynamic `<meta>` Tags on the Server](#generating-dynamic-meta-tags-on-the-server) - [Pre-Rendering into Static HTML Files](#pre-rendering-into-static-html-files) - [Injecting Data from the Server into the Page](#injecting-data-from-the-server-into-the-page) - [Running Tests](#running-tests) - [Filename Conventions](#filename-conventions) - [Command Line Interface](#command-line-interface) - [Version Control Integration](#version-control-integration) - [Writing Tests](#writing-tests) - [Testing Components](#testing-components) - [Using Third Party Assertion Libraries](#using-third-party-assertion-libraries) - [Initializing Test Environment](#initializing-test-environment) - [Focusing and Excluding Tests](#focusing-and-excluding-tests) - [Coverage Reporting](#coverage-reporting) - [Continuous Integration](#continuous-integration) - [Disabling jsdom](#disabling-jsdom) - [Snapshot Testing](#snapshot-testing) - [Editor Integration](#editor-integration) - [Debugging Tests](#debugging-tests) - [Debugging Tests in Chrome](#debugging-tests-in-chrome) - [Debugging Tests in Visual Studio Code](#debugging-tests-in-visual-studio-code) - [Developing Components in Isolation](#developing-components-in-isolation) - [Getting Started with Storybook](#getting-started-with-storybook) - [Getting Started with Styleguidist](#getting-started-with-styleguidist) - [Publishing Components to npm](#publishing-components-to-npm) - [Making a Progressive Web App](#making-a-progressive-web-app) - [Opting Out of Caching](#opting-out-of-caching) - [Offline-First Considerations](#offline-first-considerations) - [Progressive Web App Metadata](#progressive-web-app-metadata) - [Analyzing the Bundle Size](#analyzing-the-bundle-size) - [Deployment](#deployment) - [Static Server](#static-server) - [Other Solutions](#other-solutions) - [Serving Apps with Client-Side Routing](#serving-apps-with-client-side-routing) - [Building for Relative Paths](#building-for-relative-paths) - [Azure](#azure) - [Firebase](#firebase) - [GitHub Pages](#github-pages) - [Heroku](#heroku) - [Netlify](#netlify) - [Now](#now) - [S3 and CloudFront](#s3-and-cloudfront) - [Surge](#surge) - [Advanced Configuration](#advanced-configuration) - [Troubleshooting](#troubleshooting) - [`npm start` doesn’t detect changes](#npm-start-doesnt-detect-changes) - [`npm test` hangs on macOS Sierra](#npm-test-hangs-on-macos-sierra) - [`npm run build` exits too early](#npm-run-build-exits-too-early) - [`npm run build` fails on Heroku](#npm-run-build-fails-on-heroku) - [`npm run build` fails to minify](#npm-run-build-fails-to-minify) - [Moment.js locales are missing](#momentjs-locales-are-missing) - [Alternatives to Ejecting](#alternatives-to-ejecting) - [Something Missing?](#something-missing)",
  "npm_package_readmeFilename": "README.md",
  "npm_package_devDependencies_standard": "^11.0.1",
  "npm_package_devDependencies_react_test_renderer": "^16.4.1",
  "npm_package_devDependencies_enzyme_adapter_react_16": "^1.1.1",
  "npm_package_devDependencies_enzyme": "^3.3.0",
  "npm_package_devDependencies_dirty_chai": "^2.0.1",
  "npm_package_devDependencies_chai_jest_diff": "^1.0.2",
  "npm_package_devDependencies_chai_enzyme": "^1.0.0-beta.1",
  "npm_package_devDependencies_chai": "^4.1.2",
  "npm_package_devDependencies_babel_eslint": "^8.2.3",
  "npm_package_standard_parser": "babel-eslint",
  "npm_package_scripts_eject": "react-scripts eject",
  "npm_package_scripts_test": "react-scripts test --env=jsdom",
  "npm_package_scripts_build": "react-scripts build",
  "npm_package_scripts_start": "react-scripts start",
  "npm_package_dependencies_styled_components": "^3.3.2",
  "npm_package_dependencies_react_swipeable": "^4.3.0",
  "npm_package_dependencies_react_spring": "^5.3.17",
  "npm_package_dependencies_react_scripts": "1.1.4",
  "npm_package_dependencies_react_router_dom": "^4.3.1",
  "npm_package_dependencies_react_router": "^4.3.1",
  "npm_package_dependencies_react_markdown": "^3.3.3",
  "npm_package_dependencies_react_i18next": "^7.7.0",
  "npm_package_dependencies_react_dom": "^16.4.1",
  "npm_package_dependencies_react": "^16.4.1",
  "npm_package_dependencies_prop_types": "^15.6.1",
  "npm_package_dependencies_i18next": "^11.3.3",
  "npm_package_dependencies_classnames": "^2.2.6",
  "npm_package_private": "true",
  "npm_package_version": "0.1.0",
  "npm_package_name": "mobitec-vidactic",
  "npm_config_version_tag_prefix": "v",
  "npm_config_version_git_tag": "true",
  "npm_config_version_commit_hooks": "true",
  "npm_config_version_git_sign": "",
  "npm_config_version_git_message": "v%s",
  "npm_config_init_version": "1.0.0",
  "npm_config_init_license": "MIT",
  "npm_config_save_prefix": "^",
  "npm_config_bin_links": "true",
  "npm_config_ignore_scripts": "",
  "npm_config_ignore_optional": "",
  "npm_config_registry": "https://registry.yarnpkg.com",
  "npm_config_strict_ssl": "true",
  "npm_config_user_agent": "yarn/1.7.0 npm/? node/v10.4.1 darwin x64",
  "npm_config_python": "/usr/bin/python"
}
✨  Done in 0.13s.